We are running Artifactory OSS 7.4.3 in a couple environments, all Linux (RHEL 7). They are using local repositories with standard downloads/uploads of Maven artifacts. Two of those environments have encountered a "segmentation violation" error in the past few weeks. I have not been able to find any documentation of this error occurring during regular operation. My question is how should I go about troubleshooting the error?
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x576a4f]
After this happens, the service is unavailable until someone restarts Artifactory. It shows up in the console.log file, but the surrounding logging does not appear to be related aside from the following stack trace (which looks nearly identical in the two separate instances).
goroutine 20767483 [running]:
bufio.(*Writer).Available(...)
/go/src/bufio/bufio.go:610
bufio.(*Writer).WriteString(0x0, 0x2e1d3b6, 0x19, 0x40e076, 0x7f89b90d56d0, 0x67)
/go/src/bufio/bufio.go:691 +0x7f
net/http.(*expectContinueReader).Read(0xc00081c9e0, 0xc001170000, 0x210c, 0x210c, 0x7f89b90d56d0, 0x0, 0x10)
/go/src/net/http/server.go:888 +0x13b
github.com/containous/traefik/middlewares/accesslog.(*captureRequestReader).Read(0xc00081cc00, 0xc001170000, 0x210c, 0x210c, 0x26537a0, 0xc00020ad01, 0xc001170000)
/go/pkg/mod/github.com/omerkay/traefik#v1.7.22-h2c/middlewares/accesslog/capture_request_reader.go:11 +0x51
io.(*LimitedReader).Read(0xc001096240, 0xc001170000, 0x210c, 0x210c, 0x0, 0xc000bf4800, 0x40bf28)
/go/src/io/io.go:448 +0x63
io.copyBuffer(0x33338e0, 0xc001069050, 0x332fba0, 0xc001096240, 0xc001170000, 0x210c, 0x210c, 0x5, 0xc000bf49b0, 0x5)
/go/src/io/io.go:402 +0x122
io.Copy(...)
/go/src/io/io.go:364
net.genericReadFrom(0x3330720, 0xc000f9a660, 0x332fba0, 0xc001096240, 0x0, 0x0, 0x2cd0600)
/go/src/net/net.go:625 +0x9a
net.(*TCPConn).readFrom(0xc000f9a660, 0x332fba0, 0xc001096240, 0xc000bf49e8, 0x40c1fa, 0x28acde0)
/go/src/net/tcpsock_posix.go:54 +0xe2
net.(*TCPConn).ReadFrom(0xc000f9a660, 0x332fba0, 0xc001096240, 0x7f89b4e977e8, 0xc000f9a660, 0x1)
/go/src/net/tcpsock.go:103 +0x4d
io.copyBuffer(0x3330720, 0xc000f9a660, 0x332fba0, 0xc001096240, 0x0, 0x0, 0x0, 0x29fdba0, 0x7f89b4d0f001, 0x7f89b4e977c8)
/go/src/io/io.go:388 +0x2ed
io.Copy(...)
/go/src/io/io.go:364
net/http.persistConnWriter.ReadFrom(0xc000bed680, 0x332fba0, 0xc001096240, 0x7f89b4e977c8, 0xc000bed680, 0x1)
/go/src/net/http/transport.go:1600 +0x85
bufio.(*Writer).ReadFrom(0xc000aef980, 0x332fba0, 0xc001096240, 0x7f89b4cffcc8, 0xc000aef980, 0x1)
/go/src/bufio/bufio.go:713 +0x34a
io.copyBuffer(0x332bd20, 0xc000aef980, 0x332fba0, 0xc001096240, 0x0, 0x0, 0x0, 0xc000bf4c38, 0x40e8e8, 0x20)
/go/src/io/io.go:388 +0x2ed
io.Copy(...)
/go/src/io/io.go:364
net/http.(*transferWriter).doBodyCopy(0xc0008f4640, 0x332bd20, 0xc000aef980, 0x332fba0, 0xc001096240, 0x0, 0xc000bf4ee0, 0xc000e484b0)
/go/src/net/http/transfer.go:400 +0x6a
net/http.(*transferWriter).writeBody(0xc0008f4640, 0x332bd20, 0xc000aef980, 0x2, 0x2)
/go/src/net/http/transfer.go:359 +0x6da
net/http.(*Request).write(0xc000e9fa00, 0x332bd20, 0xc000aef980, 0x0, 0x0, 0xc00081ce20, 0x0, 0x0)
/go/src/net/http/request.go:682 +0x6d3
net/http.(*persistConn).writeLoop(0xc000bed680)
/go/src/net/http/transport.go:2208 +0x1c8
created by net/http.(*Transport).dialConn
/go/src/net/http/transport.go:1576 +0xb32
This is due to a bug in the Go runtime used at that time (1.14.2), for more details see https://groups.google.com/g/golang-announce/c/XZNfaiwgt2w/m/E6gHDs32AQAJ
It's been fixed starting from Artifactory 7.7.0, so you can just upgrade to the latest release (7.10.6 when writing this message)
Related
I am trying to use the following method:
response,err:=http.Get("https://support.microsoft.com")
It is working as expected. But when I call it with "https://samsung.com", it is throwing fatal exception that I can not handle.
A code sample:
package main
import (
"fmt"
"net/http"
)
func main() {
_, err := http.Get("http://support.microsoft.com")
if err != nil {
fmt.Println(err)
}
}
and here is the error:
panic: cipher.NewCBCEncrypter: IV length must equal block size
goroutine 55 [running]:
crypto/cipher.NewCBCEncrypter(0x7c7680, 0xc0001cd0b0, 0xc0000c03c8, 0x10, 0x20, 0x0, 0x0)
C:/Go/src/crypto/cipher/cbc.go:47 +0x139
crypto/tls.cipherAES(0xc0000c0388, 0x20, 0x60, 0xc0000c03c8, 0x10, 0x20, 0x0, 0x20, 0xc00008c156)
C:/Go/src/crypto/tls/cipher_suites.go:139 +0xe2
crypto/tls.(*clientHandshakeState).establishKeys(0xc0001dfdc8, 0x0, 0x0)
C:/Go/src/crypto/tls/handshake_client.go:625 +0x20c
crypto/tls.(*clientHandshakeState).handshake(0xc0001dfdc8, 0xc0000b7200, 0x0)
C:/Go/src/crypto/tls/handshake_client.go:402 +0x426
crypto/tls.(*Conn).clientHandshake(0xc00003dc00, 0x0, 0x0)
C:/Go/src/crypto/tls/handshake_client.go:208 +0x2d4
crypto/tls.(*Conn).Handshake(0xc00003dc00, 0x0, 0x0)
C:/Go/src/crypto/tls/conn.go:1343 +0xf6
net/http.(*persistConn).addTLS.func2(0x0, 0xc00003dc00, 0xc0000cc7d0, 0xc000093da0)
C:/Go/src/net/http/transport.go:1190 +0x49
created by net/http.(*persistConn).addTLS
C:/Go/src/net/http/transport.go:1186 +0x1b2
i just fixed my problem by updating go from 1.12.4 to 1.12.5.
thanks to #Markus-W-Mahlberg
I'm using R blogdown blogdown:::serve_site(),and the result is below:
Error in shell(cmd, mustWork = TRUE, intern = intern) :
'"C:\Users\xsong\AppData\Roaming\Hugo\hugo.exe" new site "." -f toml' execution failed with error code 1
In addition: Warning message:
In blogdown::new_site() : The directory '.' is not empty
> blogdown::new_site()
Congratulations! Your new Hugo site is created in F:\wwe.
Just a few more steps and you're ready to go:
1. Download a theme into the same-named folder.
Choose a theme from https://themes.gohugo.io/, or
create your own with the "hugo new theme <THEMENAME>" command.
2. Perhaps you want to add some content. You can add single files
with "hugo new <SECTIONNAME>\<FILENAME>.<FORMAT>".
3. Start the built-in live server via "hugo server".
Visit https://gohugo.io/ for quickstart guide and full documentation.
trying URL 'https://github.com/yihui/hugo-lithium/archive/master.zip'
downloaded 117 KB
processing 7 content files
Building sites 鈥?panic: Too many homes
goroutine 76 [running]:
github.com/gohugoio/hugo/hugolib.(*HugoSites).createMissingPages(0xc00030f180, 0x0, 0x0)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:627 +0x111f
github.com/gohugoio/hugo/hugolib.(*HugoSites).assemble(0xc00030f180, 0xc000389c00, 0xc0005cdc70, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:245 +0x141
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2.2()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:98 +0x43
runtime/trace.WithRegion(0x14f5060, 0xc0004d4ba0, 0x129dfd2, 0x8, 0xc0005cdd20)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2(0xc00049bdc0, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:100 +0x244
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func3()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:109 +0x36
runtime/trace.WithRegion(0x14f5060, 0xc0004d4ba0, 0x129b050, 0x7, 0xc00049bec8)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc00030f180, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:111 +0x7c4
github.com/gohugoio/hugo/commands.(*commandeer).buildSites(...)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:763
github.com/gohugoio/hugo/commands.(*commandeer).fullBuild.func3(0x8, 0x134c5d8)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:313 +0x80
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc0004d4b70, 0xc0002f0d30)
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:58 +0x5e
created by golang.org/x/sync/errgroup.(*Group).Go
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:55 +0x6d
Building sites 鈥?panic: Too many homes
goroutine 85 [running]:
github.com/gohugoio/hugo/hugolib.(*HugoSites).createMissingPages(0xc000435180, 0x0, 0x0)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:627 +0x111f
github.com/gohugoio/hugo/hugolib.(*HugoSites).assemble(0xc000435180, 0xc0003bce00, 0xc0005e1c70, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:245 +0x141
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2.2()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:98 +0x43
runtime/trace.WithRegion(0x14f5060, 0xc0003c13e0, 0x129dfd2, 0x8, 0xc0005e1d20)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2(0xc000355dc0, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:100 +0x244
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func3()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:109 +0x36
runtime/trace.WithRegion(0x14f5060, 0xc0003c13e0, 0x129b050, 0x7, 0xc000355ec8)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc000435180, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:111 +0x7c4
github.com/gohugoio/hugo/commands.(*commandeer).buildSites(...)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:763
github.com/gohugoio/hugo/commands.(*commandeer).fullBuild.func3(0x8, 0x134c5d8)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:313 +0x80
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc0003c13b0, 0xc000215ae0)
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:58 +0x5e
created by golang.org/x/sync/errgroup.(*Group).Go
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:55 +0x6d
系统找不到指定的路径。
Error in shell(cmd, mustWork = TRUE, intern = intern) :
'"C:\Users\xsong\AppData\Roaming\Hugo\hugo.exe" -b / -D -F -d "public" --themesDir themes -t hugo-lithium' execution failed with error code 1
> blogdown:::serve_site()
Building sites 鈥?panic: Too many homes
goroutine 73 [running]:
github.com/gohugoio/hugo/hugolib.(*HugoSites).createMissingPages(0xc0002e12d0, 0x0, 0x0)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:627 +0x111f
github.com/gohugoio/hugo/hugolib.(*HugoSites).assemble(0xc0002e12d0, 0xc000472000, 0xc000549c70, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:245 +0x141
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2.2()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:98 +0x43
runtime/trace.WithRegion(0x14f5060, 0xc0001b2120, 0x129dfd2, 0x8, 0xc000549d20)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2(0xc0005afdc0, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:100 +0x244
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func3()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:109 +0x36
runtime/trace.WithRegion(0x14f5060, 0xc0001b2120, 0x129b050, 0x7, 0xc0005afec8)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc0002e12d0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:111 +0x7c4
github.com/gohugoio/hugo/commands.(*commandeer).buildSites(...)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:763
github.com/gohugoio/hugo/commands.(*commandeer).fullBuild.func3(0x8, 0x134c5d8)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:313 +0x80
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc0001b20f0, 0xc0005800e0)
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:58 +0x5e
created by golang.org/x/sync/errgroup.(*Group).Go
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:55 +0x6d
Building sites 鈥?panic: Too many homes
goroutine 31 [running]:
github.com/gohugoio/hugo/hugolib.(*HugoSites).createMissingPages(0xc000097180, 0x0, 0x0)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites.go:627 +0x111f
github.com/gohugoio/hugo/hugolib.(*HugoSites).assemble(0xc000097180, 0xc000298000, 0xc0005efc70, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:245 +0x141
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2.2()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:98 +0x43
runtime/trace.WithRegion(0x14f5060, 0xc00040c4e0, 0x129dfd2, 0x8, 0xc0005efd20)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func2(0xc0002b9dc0, 0x20)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:100 +0x244
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func3()
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:109 +0x36
runtime/trace.WithRegion(0x14f5060, 0xc00040c4e0, 0x129b050, 0x7, 0xc0002b9ec8)
/usr/local/go/src/runtime/trace/annotation.go:137 +0xf0
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc000097180, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:111 +0x7c4
github.com/gohugoio/hugo/commands.(*commandeer).buildSites(...)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:763
github.com/gohugoio/hugo/commands.(*commandeer).fullBuild.func3(0x8, 0x134c5d8)
/go/src/github.com/gohugoio/hugo/commands/hugo.go:313 +0x80
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc00040c390, 0xc000112030)
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:58 +0x5e
created by golang.org/x/sync/errgroup.(*Group).Go
/go/pkg/mod/golang.org/x/sync#v0.0.0-20180314180146-1d60e4601c6f/errgroup/errgroup.go:55 +0x6d
系统找不到指定的路径。
Error in shell(cmd, mustWork = TRUE, intern = intern) :
'"C:\Users\xsong\AppData\Roaming\Hugo\hugo.exe" -b / -D -F -d "public" --themesDir themes -t hugo-lithium' execution failed with error code 1
It seems that there are some problems of hugo lithium theme. I also cannot successfully use blogdown::new_site() to bulid a new site. I have tried to reinstall blogdown and hugo, but it does not work.
Please help me.
Here is an extract of my code:
func sendTo(url string, someDataPoints [] DataPoint) {
ro := &grequests.RequestOptions{JSON: someDataPoints, InsecureSkipVerify: false}
grequests.Post(url, ro)
return
}
func forward(someDataPoints []DataPoint) int {
endpoint := "https://example.org"
go sendTo(endpoint, someDataPoints)
}
The function forward is called something like 100 times per second. The program works for thirty hour or so and ends up failing with the following error:
goroutine 265125012 [semacquire, 41 minutes]:
sync.runtime_notifyListWait(0xc4204be2d0, 0x1bb56b6)
/usr/local/go/src/runtime/sema.go:510 +0x10b
sync.(*Cond).Wait(0xc4204be2c0)
/usr/local/go/src/sync/cond.go:56 +0x80
net/http.(*http2ClientConn).awaitOpenSlotForRequest(0xc420d5e000, 0xc42c167000, 0x0, 0x0)
/usr/local/go/src/net/http/h2_bundle.go:7528 +0x11d
net/http.(*http2ClientConn).roundTrip(0xc420d5e000, 0xc42c167000, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/h2_bundle.go:7336 +0x110
net/http.(*http2Transport).RoundTripOpt(0xc4200100f0, 0xc42c167000, 0xffffffffffffff00, 0x0, 0x40bac0, 0x705e50)
/usr/local/go/src/net/http/h2_bundle.go:6929 +0x150
net/http.(*http2Transport).RoundTrip(0xc4200100f0, 0xc42c167000, 0xc42c1a04c0, 0x0, 0xc42c1a0438)
/usr/local/go/src/net/http/h2_bundle.go:6891 +0x3a
net/http.http2noDialH2RoundTripper.RoundTrip(0xc4200100f0, 0xc42c167000, 0x7fff668abf02, 0x5, 0xc42016a088)
/usr/local/go/src/net/http/h2_bundle.go:991 +0x39
net/http.(*Transport).RoundTrip(0x8aa800, 0xc42c167000, 0x8aa800, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:380 +0xc36
net/http.send(0xc42c167000, 0x745660, 0x8aa800, 0x0, 0x0, 0x0, 0xc44002b628, 0xb000000000411729, 0xc420d52b50, 0x1)
/usr/local/go/src/net/http/client.go:252 +0x185
net/http.(*Client).send(0x8afa20, 0xc42c167000, 0x0, 0x0, 0x0, 0xc44002b628, 0x0, 0x1, 0x698620)
/usr/local/go/src/net/http/client.go:176 +0xfa
net/http.(*Client).Do(0x8afa20, 0xc42c167000, 0x7fff668abf02, 0x3a, 0xc42bcc5b80)
/usr/local/go/src/net/http/client.go:615 +0x28d
github.com/levigross/grequests.buildRequest(0x705a0f, 0x4, 0x7fff668abf02, 0x3a, 0xc42bcc5b80, 0x8afa20, 0x8, 0x18, 0xc431e455a0)
/go/src/github.com/levigross/grequests/request.go:194 +0x189
github.com/levigross/grequests.doRegularRequest(0x705a0f, 0x4, 0x7fff668abf02, 0x3a, 0xc42bcc5b80, 0x690380, 0x1, 0xc431e455a0)
/go/src/github.com/levigross/grequests/request.go:136 +0x6f
github.com/levigross/grequests.Post(0x7fff668abf02, 0x3a, 0xc42bcc5b80, 0xc431e455a0, 0x4, 0xc42c1703c0)
/go/src/github.com/levigross/grequests/base.go:41 +0x54
main.sendTo(0x7fff668abf02, 0x3a, 0xc42bcd33b0, 0x1, 0x1, 0x0, 0x0)
/go/src/github.com/SomeCompany/SomeProduct/cmd/SomeCli/main.go:66 +0xdd
created by main.forward
/go/src/github.com/SomeCompany/SomeProduct/cmd/SomeCli/main.go:80 +0xc8
What could explain this issue?
It does not seem to have an actual error displayed in there. Just a stack trace. I'm not sure why.
What I do see is that you appear to just launch goroutines without any limit. What does your program do if it cannot forward and complete sendTo requests faster than they arrive?
I think that at some point Go will run out of memory for goroutine stacks, or something else will overflow. I'd expect some sort of "out of memory" error, but I don't see one there.
Nevertheless, that is my best guess: some sort of resource exhaustion caused by creating more goroutines than are finishing.
As visible in the official documentation as well as almost everywhere else online, the common pattern for handling http client errors is the following:
req, err := http.NewRequest("GET", "http://example.com", nil)
req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)
if err != nil {
// handle error
}
defer resp.Body.Close()
Reading the docs about the methods on the http client, I'm not able to understand if it is possible to receive both resp and err not nil, it seems like it's possible if we consider what is written in the Do method documentation:
The request Body, if non-nil, will be closed by the underlying
Transport, even on errors.
On error, any Response can be ignored. A non-nil Response with a
non-nil error only occurs when CheckRedirect fails, and even then the
returned Response.Body is already closed.
Therefore my questions are the following:
Is it possible to receive non-nil resp and err at the same time?
If it is possible, and in my program I end up receiving a lot of errors, and I return or panic in the //handle error piece of the code shown above, thus never reaching the defer right after, is it possible that on the long run I end up having too many open bodies that the transport hasn't been able to close?
Context Addendum :
The problem I encounter is that, after a while, the program crashes with the following big print of goroutines on the stdErr, and following the trace I end up to a piece of code that seems normal, unless something bad happens if an error is encountered and there's a responseBody upon which no defer close will be made, but since the official docs say not to worry about it, the problem must be elsewhere...
Stderr logs
Display timestamps
net/http.(*persistConn).readLoop(0xc4244e0240)
/usr/local/go/src/net/http/transport.go:1474 +0x196
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 194055 [select, 2 minutes]:
net/http.(*persistConn).readLoop(0xc42421ec60)
/usr/local/go/src/net/http/transport.go:1599 +0x9ec
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 215944 [IO wait]:
net.runtime_pollWait(0x7f63736f0628, 0x72, 0x21b)
/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc420963568, 0x72, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc420963568, 0xc422289000, 0x1000)
/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc420963500, 0xc422289000, 0x1000, 0x1000, 0x0, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42025bbb8, 0xc422289000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:181 +0x70
net/http.(*persistConn).Read(0xc4217af8c0, 0xc422289000, 0x1000, 0x1000, 0xc420b33400, 0x8b61a3, 0xc423dd6b80)
/usr/local/go/src/net/http/transport.go:1316 +0x14b
bufio.(*Reader).fill(0xc421af0060)
/usr/local/go/src/bufio/bufio.go:97 +0x117
bufio.(*Reader).Peek(0xc421af0060, 0x1, 0xc421af01e0, 0xc420536c80, 0xc420b17e00, 0x60, 0xc420536c60)
/usr/local/go/src/bufio/bufio.go:129 +0x67
net/http.(*persistConn).readLoop(0xc4217af8c0)
/usr/local/go/src/net/http/transport.go:1474 +0x196
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 199855 [select, 1 minutes]:
net/http.(*persistConn).writeLoop(0xc421db1320)
/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1118 +0xa5a
goroutine 198707 [select, 1 minutes]:
net/http.(*persistConn).readLoop(0xc4236ea000)
/usr/local/go/src/net/http/transport.go:1599 +0x9ec
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 192577 [select, 2 minutes]:
net/http.(*persistConn).readLoop(0xc424a8fc20)
/usr/local/go/src/net/http/transport.go:1599 +0x9ec
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 213681 [select]:
net/http.(*persistConn).writeLoop(0xc42455e6c0)
/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1118 +0xa5a
goroutine 190222 [select, 2 minutes]:
net/http.(*persistConn).writeLoop(0xc4238617a0)
/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1118 +0xa5a
goroutine 208970 [select, 1 minutes]:
net/http.(*persistConn).writeLoop(0xc4234530e0)
/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1118 +0xa5a
goroutine 219699 [select]:
net/http.(*persistConn).writeLoop(0xc42155cb40)
/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1118 +0xa5a
goroutine 221664 [select]:
net/http.setRequestCancel.func3(0x0, 0xc4231af680, 0xc423657000, 0xc4214aeecc, 0xc422f926c0)
/usr/local/go/src/net/http/client.go:320 +0x17c
created by net/http.setRequestCancel
/usr/local/go/src/net/http/client.go:330 +0x287
goroutine 220550 [select]:
net/http.(*persistConn).readLoop(0xc4218f0c60)
/usr/local/go/src/net/http/transport.go:1599 +0x9ec
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 216169 [IO wait]:
net.runtime_pollWait(0x7f6373700fb0, 0x72, 0x221)
/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc4212fdb18, 0x72, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc4212fdb18, 0xc42393c000, 0x1000)
/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc4212fdab0, 0xc42393c000, 0x1000, 0x1000, 0x0, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42300aa38, 0xc42393c000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:181 +0x70
net/http.(*persistConn).Read(0xc422102c60, 0xc42393c000, 0x1000, 0x1000, 0xc423d30820, 0xc42002a800, 0xc424422b80)
/usr/local/go/src/net/http/transport.go:1316 +0x14b
bufio.(*Reader).fill(0xc4220598c0)
/usr/local/go/src/bufio/bufio.go:97 +0x117
bufio.(*Reader).Peek(0xc4220598c0, 0x1, 0xc422059a40, 0xc420535c80, 0xc422059700, 0x60, 0xc420535c60)
/usr/local/go/src/bufio/bufio.go:129 +0x67
net/http.(*persistConn).readLoop(0xc422102c60)
/usr/local/go/src/net/http/transport.go:1474 +0x196
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 213706 [select]:
net/http.(*persistConn).writeLoop(0xc42321d200)
/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1118 +0xa5a
goroutine 214335 [select]:
net/http.(*persistConn).writeLoop(0xc4230d7560)
/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1118 +0xa5a
goroutine 221651 [IO wait]:
net.runtime_pollWait(0x7f63736eff38, 0x72, 0x254)
/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc422449b18, 0x72, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc422449b18, 0xc423d93000, 0x1000)
/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc422449ab0, 0xc423d93000, 0x1000, 0x1000, 0x0, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc421eb21b8, 0xc423d93000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:181 +0x70
net/http.(*persistConn).Read(0xc422e5b440, 0xc423d93000, 0x1000, 0x1000, 0x8cc888, 0x0, 0xc42347bb80)
/usr/local/go/src/net/http/transport.go:1316 +0x14b
bufio.(*Reader).fill(0xc422f2c960)
/usr/local/go/src/bufio/bufio.go:97 +0x117
bufio.(*Reader).Peek(0xc422f2c960, 0x1, 0xc422f2d6e0, 0xc420b8ec80, 0xc42180ff00, 0x60, 0xc420b8ec60)
/usr/local/go/src/bufio/bufio.go:129 +0x67
net/http.(*persistConn).readLoop(0xc422e5b440)
/usr/local/go/src/net/http/transport.go:1474 +0x196
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 221670 [IO wait]:
net.runtime_pollWait(0x7f63736ff7b0, 0x72, 0x259)
/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc422449b88, 0x72, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc422449b88, 0xc423f28000, 0x1000)
/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc422449b20, 0xc423f28000, 0x1000, 0x1000, 0x0, 0xa85c40, 0xa81350)
/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc423eac3c8, 0xc423f28000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:181 +0x70
net/http.(*persistConn).Read(0xc4235930e0, 0xc423f28000, 0x1000, 0x1000, 0xa82dc0, 0xc42000e0b0, 0xc423be7b80)
/usr/local/go/src/net/http/transport.go:1316 +0x14b
bufio.(*Reader).fill(0xc422bb70e0)
/usr/local/go/src/bufio/bufio.go:97 +0x117
bufio.(*Reader).Peek(0xc422bb70e0, 0x1, 0xc422bb7320, 0xc424191480, 0xc4237a4820, 0x0, 0xc422ac9138)
/usr/local/go/src/bufio/bufio.go:129 +0x67
net/http.(*persistConn).readLoop(0xc4235930e0)
/usr/local/go/src/net/http/transport.go:1474 +0x196
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 213543 [select]:
net/http.(*persistConn).readLoop(0xc424795c20)
/usr/local/go/src/net/http/transport.go:1599 +0x9ec
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:1117 +0xa35
goroutine 220529 [select]:
net/http.(*persistConn).roundTrip(0xc4215fd680, 0xc4212c5c80, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1898 +0x974
net/http.(*Transport).RoundTrip(0xc420847b30, 0xc421248800, 0xc420847b30, 0xed15b2cf4, 0x16cd81f7)
/usr/local/go/src/net/http/transport.go:391 +0x74c
net/http.send(0xc421248700, 0xa84080, 0xc420847b30, 0xed15b2cf4, 0x16cd81f7, 0xab7060, 0x0, 0x8, 0xc4213a2a80, 0x40f258)
/usr/local/go/src/net/http/client.go:249 +0x162
net/http.(*Client).send(0xc42075ed20, 0xc421248700, 0xed15b2cf4, 0x16cd81f7, 0xab7060, 0xc4213a2a80, 0x0, 0x1, 0x4084fe)
/usr/local/go/src/net/http/client.go:173 +0x108
net/http.(*Client).Do(0xc42075ed20, 0xc421248700, 0xa, 0x8b359b, 0x5)
/usr/local/go/src/net/http/client.go:595 +0x254
github.com/myCompanyName/gojsonrpc.(*Client).sendJsonRequest(0xc42078c6e0, 0xc4215fd320, 0xbb, 0x11a, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/ubuntu/go/src/github.com/myCompanyName/gojsonrpc/client.go:45 +0x2f2
github.com/myCompanyName/gojsonrpc.(*Client).Run(0xc42078c6e0, 0x8be6b2, 0x1d, 0x838780, 0xc420789ce0, 0x7fb2e0, 0xc4212c5b40, 0x1, 0xe)
/home/ubuntu/go/src/github.com/myCompanyName/gojsonrpc/client.go:72 +0x219
github.com/myCompanyName/app/connectors/vendor.(*Connector).ReadStatus(0xc42078aa30, 0xc4212c5a60, 0xd, 0xc4212c5a6e, 0x7, 0xc4212c59c0, 0x1d, 0x0, 0x0, 0x0, ...)
/home/ubuntu/go/src/github.com/myCompanyName/app/connectors/vendor/tickets.go:52 +0x386
github.com/myCompanyName/app/obscuredPkgName/connabslayer.(*ConnAbsLayer).ReadMetrics(0xc42075ac40, 0xc4212c5a60, 0x15, 0xc4212c59c0, 0x1d, 0xc42121eb30, 0xf)
/home/ubuntu/go/src/github.com/myCompanyName/app/obscuredPkgName/connabslayer/connector_abstraction_layer.go:145 +0xdc
github.com/myCompanyName/app/obscuredPkgName/updater/plugins.(*UpdaterPlugin).SyncPluggedData(0xc42078c820, 0xc4208b9ef0, 0x28, 0xf)
/home/ubuntu/go/src/github.com/myCompanyName/app/obscuredPkgName/updater/plugins/vendor_plugin.go:69 +0x1e1
github.com/myCompanyName/app/obscuredPkgName/updater.(*Updater).syncData.func1(0xc420763a00, 0xc4208b9ef0, 0x28, 0xc4201824f0, 0xf)
/home/ubuntu/go/src/github.com/myCompanyName/app/obscuredPkgName/updater/updater.go:127 +0xf6
created by github.com/myCompanyName/app/obscuredPkgName/updater.(*Updater).syncData
/home/ubuntu/go/src/github.com/myCompanyName/app/obscuredPkgName/updater/updater.go:131 +0x17b
// AND SO ON
Solution:
The problem was elsewhere, as visible in the comments below, but the question might be useful for somebody else asking the same.
Yes, they can both be non-nil in one situation, apparently. From the source, we see:
if err != nil {
// Special case for Go 1 compatibility: return both the response
// and an error if the CheckRedirect function failed.
// See https://golang.org/issue/3795
// The resp.Body has already been closed.
ue := uerr(err)
ue.(*url.Error).URL = loc
return resp, ue
}
Every other return is returning either a response and nil err, or a nil response and non-nil error.
So for the questions above:
Yes
Can't happen, for the only case in which both a body and an error are non-nil, the body has already been closed
I want to create a web app on GAE in Go and I need it to listen to a custom port. How do I set it up? I tried to use http.ListenAndServe(":12345", nil) in the sandbox, but got this in my console:
WARNING 2011-10-07 20:01:01,252 urlfetch_stub.py:108] No ssl package found. urlfetch
will not be able to validate SSL certificates.
INFO 2011-10-07 20:01:01,847 appengine_rpc.py:159] Server: appengine.google.com
INFO 2011-10-07 20:01:01,855 appcfg.py:463] Checking for updates to the SDK.
INFO 2011-10-07 20:01:04,625 appcfg.py:480] The SDK is up to date.
WARNING 2011-10-07 20:01:04,625 datastore_file_stub.py:512] Could not read datastore data from /var/folders/e0/e0U5NtMXFHOB6jVwkVhsnE+++TM/-Tmp-/dev_appserver.datastore
INFO 2011-10-07 20:01:04,627 rdbms_sqlite.py:58] Connecting to SQLite database '' with file '/var/folders/e0/e0U5NtMXFHOB6jVwkVhsnE+++TM/-Tmp-/dev_appserver.rdbms'
WARNING 2011-10-07 20:01:04,633 dev_appserver.py:4748] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO 2011-10-07 20:01:04,641 dev_appserver_multiprocess.py:637] Running application tpbitblock on port 8080: http://localhost:8080
INFO 2011-10-07 20:01:08,448 __init__.py:365] building _go_app
INFO 2011-10-07 20:01:11,105 __init__.py:351] running _go_app
throw: init rescheduling
runtime.throw+0x40 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/runtime.c:102
runtime.throw(0x278c7f, 0xdc73)
schedule+0x3e /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:535
schedule(0x10803000, 0x10803000)
runtime.mcall+0x3a /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:174
runtime.mcall(0x10803000, 0x0)
goroutine 2 [1]:
net.*pollServer·Run /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:213
net.*pollServer·Run(0x10801c90, 0x0)
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
net.newPollServer+0x2dd /private/tmp/appengine/google_appengine/goroot/src/pkg/net/newpollserver.go:39
goroutine 1 [4]:
runtime.gosched+0x4d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:603
runtime.gosched()
runtime.chanrecv+0x14d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:361
runtime.chanrecv(0x1081d900, 0x30800e6c, 0x0, 0x0, 0x0, ...)
runtime.chanrecv1+0x3f /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:424
runtime.chanrecv1(0x1081d900, 0x1081e580)
net.*pollServer·WaitRead+0x47 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x10801c90, 0x1081e580, 0x0)
net.*netFD·accept+0x2ae /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:605
net.*netFD·accept(0x1081e580, 0x45716, 0x0, 0x0, 0x0, ...)
net.*TCPListener·AcceptTCP+0x53 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:272
net.*TCPListener·AcceptTCP(0x108008b8, 0x30800f00, 0x0, 0x0)
net.*TCPListener·Accept+0x36 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:282
net.*TCPListener·Accept(0x108008b8, 0x0, 0x0, 0x0, 0x0, ...)
http.*Server·Serve+0x96 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:868
http.*Server·Serve(0x10839d20, 0x10839e20, 0x108008b8, 0x0, 0x0, ...)
http.*Server·ListenAndServe+0x9c /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:855
http.*Server·ListenAndServe(0x10839d20, 0x10839d20, 0x406)
http.ListenAndServe+0x52 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:920
http.ListenAndServe(0x155640, 0x6, 0x0, 0x0, 0x0, ...)
BitBlock.init·1+0x174 BitBlock/BitBlock.go:43
BitBlock.init·1()
BitBlock.init+0x70 BitBlock/BitBlock.go:0
BitBlock.init()
main.init+0x39 _go_main.go:0
main.init()
runtime.mainstart+0x5 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:91
runtime.mainstart()
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
_rt0_386+0xbf /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:80
ERROR 2011-10-07 20:01:12,196 dev_appserver.py:4200] Exception encountered handling request
Traceback (most recent call last):
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4143, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4049, in _Dispatch
base_env_dict=env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 616, in Dispatch
base_env_dict=base_env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 3120, in Dispatch
self._module_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 2972, in ExecuteCGI
env, infile, outfile)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 399, in execute_go_cgi
GO_APP.make_and_run()
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 362, in make_and_run
wait_until_go_app_ready(self.proc.pid)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 285, in wait_until_go_app_ready
raise Exception('unable to start ' + GO_APP_NAME)
Exception: unable to start _go_app
INFO 2011-10-07 20:01:12,242 dev_appserver.py:4247] "GET / HTTP/1.1" 500 -
INFO 2011-10-07 20:01:12,505 __init__.py:351] running _go_app
throw: init rescheduling
runtime.throw+0x40 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/runtime.c:102
runtime.throw(0x278c7f, 0xdc73)
schedule+0x3e /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:535
schedule(0x10803000, 0x10803000)
runtime.mcall+0x3a /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:174
runtime.mcall(0x10803000, 0x0)
goroutine 2 [1]:
net.*pollServer·Run /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:213
net.*pollServer·Run(0x10801c90, 0x0)
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
net.newPollServer+0x2dd /private/tmp/appengine/google_appengine/goroot/src/pkg/net/newpollserver.go:39
goroutine 1 [4]:
runtime.gosched+0x4d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:603
runtime.gosched()
runtime.chanrecv+0x14d /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:361
runtime.chanrecv(0x1081d900, 0x30800e6c, 0x0, 0x0, 0x0, ...)
runtime.chanrecv1+0x3f /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/chan.c:424
runtime.chanrecv1(0x1081d900, 0x1081e580)
net.*pollServer·WaitRead+0x47 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x10801c90, 0x1081e580, 0x0)
net.*netFD·accept+0x2ae /private/tmp/appengine/google_appengine/goroot/src/pkg/net/fd.go:605
net.*netFD·accept(0x1081e580, 0x45716, 0x0, 0x0, 0x0, ...)
net.*TCPListener·AcceptTCP+0x53 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:272
net.*TCPListener·AcceptTCP(0x108008b8, 0x30800f00, 0x0, 0x0)
net.*TCPListener·Accept+0x36 /private/tmp/appengine/google_appengine/goroot/src/pkg/net/tcpsock.go:282
net.*TCPListener·Accept(0x108008b8, 0x0, 0x0, 0x0, 0x0, ...)
http.*Server·Serve+0x96 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:868
http.*Server·Serve(0x10839d20, 0x10839e20, 0x108008b8, 0x0, 0x0, ...)
http.*Server·ListenAndServe+0x9c /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:855
http.*Server·ListenAndServe(0x10839d20, 0x10839d20, 0x406)
http.ListenAndServe+0x52 /private/tmp/appengine/google_appengine/goroot/src/pkg/http/server.go:920
http.ListenAndServe(0x155640, 0x6, 0x0, 0x0, 0x0, ...)
BitBlock.init·1+0x174 BitBlock/BitBlock.go:43
BitBlock.init·1()
BitBlock.init+0x70 BitBlock/BitBlock.go:0
BitBlock.init()
main.init+0x39 _go_main.go:0
main.init()
runtime.mainstart+0x5 /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:91
runtime.mainstart()
runtime.goexit /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
_rt0_386+0xbf /private/tmp/appengine/google_appengine/goroot/src/pkg/runtime/386/asm.s:80
ERROR 2011-10-07 20:01:13,530 dev_appserver.py:4200] Exception encountered handling request
Traceback (most recent call last):
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4143, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 4049, in _Dispatch
base_env_dict=env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 616, in Dispatch
base_env_dict=base_env_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 3120, in Dispatch
self._module_dict)
File "/Google App Engine/google/appengine/tools/dev_appserver.py", line 2972, in ExecuteCGI
env, infile, outfile)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 399, in execute_go_cgi
GO_APP.make_and_run()
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 362, in make_and_run
wait_until_go_app_ready(self.proc.pid)
File "/Google App Engine/google/appengine/ext/go/__init__.py", line 285, in wait_until_go_app_ready
raise Exception('unable to start ' + GO_APP_NAME)
Exception: unable to start _go_app
INFO 2011-10-07 20:01:13,531 dev_appserver.py:4247] "GET /favicon.ico HTTP/1.1" 500 -
You can't do that. App Engine doesn't allow custom http ports. App Engine environment is heavily sandboxed and not everything that you can do in pure Go (or Java or Python) is available in their respective App Engine environments.
From http://code.google.com/appengine/docs/go/overview.html:
As with the Java and Python environments, not all the standard library's functionality is available inside the sandbox. For example, attempts to open a socket or write to a file will return an os.EINVAL error.
Go apps run inside a secure "sandbox" environment with a reduced set of libraries. For instance, an app cannot write data to the local file system or make arbitrary network connections. Instead, apps use scalable services provided by App Engine to store data and communicate over the Internet.
It is indeed possible, all you need to do is goapp serve --port=3000 (or whatever port you'd like).
If you're trying to access your goapp on a VM (parallels), like I was, you can do goapp serve --host=0.0.0.0
Documentation: https://cloud.google.com/appengine/docs/go/tools/devserver#Go_Command-line_arguments