Testcase:
Echo example (javascript client --> golang server).
https://gist.github.com/tmichel/7390690
ws.go cross compiled in windows for ARM (linux/raspberry pi).
go version go1.8 windows/amd64
latest gorilla/websocket version.
Problem:
call to:
conn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)
does not return?
After one or two minutes I got an exception.
With golang ws server on windows I have no problem.
Here is the stack dump, profile and heap:
goroutine 19 [running]:
runtime/pprof.writeGoroutineStacks(0x4a1140, 0x108a1320, 0x0, 0x10811500)
C:/Go/src/runtime/pprof/pprof.go:603 +0x58
runtime/pprof.writeGoroutine(0x4a1140, 0x108a1320, 0x2, 0x20, 0x117c0)
C:/Go/src/runtime/pprof/pprof.go:592 +0x30
runtime/pprof.(*Profile).WriteTo(0x4c7b90, 0x4a1140, 0x108a1320, 0x2, 0x108a1320, 0x4cd738)
C:/Go/src/runtime/pprof/pprof.go:302 +0x2b0
net/http/pprof.handler.ServeHTTP(0x10896dc1, 0x9, 0x4a3110, 0x108a1320, 0x108acf00)
C:/Go/src/net/http/pprof/pprof.go:209 +0x168
net/http/pprof.Index(0x4a3110, 0x108a1320, 0x108acf00)
C:/Go/src/net/http/pprof/pprof.go:221 +0x17c
net/http.HandlerFunc.ServeHTTP(0x358158, 0x4a3110, 0x108a1320, 0x108acf00)
C:/Go/src/net/http/server.go:1942 +0x34
net/http.(*ServeMux).ServeHTTP(0x4cd738, 0x4a3110, 0x108a1320, 0x108acf00)
C:/Go/src/net/http/server.go:2238 +0x108
net/http.serverHandler.ServeHTTP(0x10874080, 0x4a3110, 0x108a1320, 0x108acf00)
C:/Go/src/net/http/server.go:2568 +0x7c
net/http.(*conn).serve(0x1089f4a0, 0x4a36e8, 0x10877aa0)
C:/Go/src/net/http/server.go:1825 +0x528
created by net/http.(*Server).Serve
C:/Go/src/net/http/server.go:2668 +0x234
goroutine 1 [IO wait]:
net.runtime_pollWait(0x76da2f78, 0x72, 0x0)
C:/Go/src/runtime/netpoll.go:164 +0x44
net.(*pollDesc).wait(0x108160fc, 0x72, 0x0, 0x109051c0)
C:/Go/src/net/fd_poll_runtime.go:75 +0x28
net.(*pollDesc).waitRead(0x108160fc, 0xffffffff, 0x0)
C:/Go/src/net/fd_poll_runtime.go:80 +0x24
net.(*netFD).accept(0x108160c0, 0x0, 0x4a1218, 0x109051c0)
C:/Go/src/net/fd_unix.go:430 +0x15c
net.(*TCPListener).accept(0x1080c0e0, 0x202504, 0x1089f780, 0x2fb618)
C:/Go/src/net/tcpsock_posix.go:136 +0x20
net.(*TCPListener).AcceptTCP(0x1080c0e0, 0x6983c, 0x10835f18, 0x10835f1c)
C:/Go/src/net/tcpsock.go:215 +0x3c
net/http.tcpKeepAliveListener.Accept(0x1080c0e0, 0x358080, 0x1089f740, 0x4a3760, 0x108103c0)
C:/Go/src/net/http/server.go:3044 +0x1c
net/http.(*Server).Serve(0x10874080, 0x4a31f0, 0x1080c0e0, 0x0, 0x0)
C:/Go/src/net/http/server.go:2643 +0x1ac
net/http.(*Server).ListenAndServe(0x10874080, 0x10874080, 0x1)
C:/Go/src/net/http/server.go:2585 +0x90
net/http.ListenAndServe(0x33ed25, 0x5, 0x0, 0x0, 0x108000f0, 0x108000f0)
C:/Go/src/net/http/server.go:2787 +0x70
main.main()
e:/gopath/src/ttt/ws/ws.go:21 +0x68
goroutine 4 [semacquire]:
sync.runtime_notifyListWait(0x10810508, 0x0)
C:/Go/src/runtime/sema.go:297 +0x138
sync.(*Cond).Wait(0x10810500)
C:/Go/src/sync/cond.go:57 +0x78
net/http.(*connReader).abortPendingRead(0x1084e0f0)
C:/Go/src/net/http/server.go:686 +0xbc
net/http.(*conn).hijackLocked(0x1090a120, 0x3583c8, 0x1090a168, 0x10912130, 0x76da2ff0, 0x241c08)
C:/Go/src/net/http/server.go:292 +0x2c
net/http.(*response).Hijack(0x10814090, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Go/src/net/http/server.go:1892 +0xb8
github.com/gorilla/websocket.(*Upgrader).Upgrade(0x1083ad84, 0x4a3110, 0x10814090, 0x10874100, 0x10810640, 0x15, 0x10874180, 0x0)
e:/gopath/src/github.com/gorilla/websocket/server.go:164 +0x314
github.com/gorilla/websocket.Upgrade(0x4a3110, 0x10814090, 0x10874100, 0x10810640, 0x400, 0x400, 0x0, 0x0, 0x10818024)
e:/gopath/src/github.com/gorilla/websocket/server.go:269 +0x68
main.wsHandler(0x4a3110, 0x10814090, 0x10874100)
e:/gopath/src/ttt/ws/ws.go:38 +0xac
net/http.HandlerFunc.ServeHTTP(0x357fa4, 0x4a3110, 0x10814090, 0x10874100)
C:/Go/src/net/http/server.go:1942 +0x34
net/http.(*ServeMux).ServeHTTP(0x4cd738, 0x4a3110, 0x10814090, 0x10874100)
C:/Go/src/net/http/server.go:2238 +0x108
net/http.serverHandler.ServeHTTP(0x10874080, 0x4a3110, 0x10814090, 0x10874100)
C:/Go/src/net/http/server.go:2568 +0x7c
net/http.(*conn).serve(0x1090a120, 0x4a36e8, 0x10810460)
C:/Go/src/net/http/server.go:1825 +0x528
created by net/http.(*Server).Serve
C:/Go/src/net/http/server.go:2668 +0x234
goroutine 5 [IO wait]:
net.runtime_pollWait(0x76da2f00, 0x72, 0x1084e0fd)
C:/Go/src/runtime/netpoll.go:164 +0x44
net.(*pollDesc).wait(0x108161fc, 0x72, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_poll_runtime.go:75 +0x28
net.(*pollDesc).waitRead(0x108161fc, 0x1084e0fd, 0x1)
C:/Go/src/net/fd_poll_runtime.go:80 +0x24
net.(*netFD).Read(0x108161c0, 0x1084e0fd, 0x1, 0x1, 0x0, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_unix.go:250 +0x148
net.(*conn).Read(0x1080c0f8, 0x1084e0fd, 0x1, 0x1, 0x0, 0x0, 0x0)
C:/Go/src/net/net.go:181 +0x58
net/http.(*connReader).backgroundRead(0x1084e0f0)
C:/Go/src/net/http/server.go:656 +0x44
created by net/http.(*connReader).startBackgroundRead
C:/Go/src/net/http/server.go:652 +0xd4
goroutine 51 [IO wait]:
net.runtime_pollWait(0x76da2e10, 0x72, 0x1091a000)
C:/Go/src/runtime/netpoll.go:164 +0x44
net.(*pollDesc).wait(0x108164bc, 0x72, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_poll_runtime.go:75 +0x28
net.(*pollDesc).waitRead(0x108164bc, 0x1091a000, 0x1000)
C:/Go/src/net/fd_poll_runtime.go:80 +0x24
net.(*netFD).Read(0x10816480, 0x1091a000, 0x1000, 0x1000, 0x0, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_unix.go:250 +0x148
net.(*conn).Read(0x10878790, 0x1091a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
C:/Go/src/net/net.go:181 +0x58
net/http.(*connReader).Read(0x10896cf0, 0x1091a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
C:/Go/src/net/http/server.go:754 +0x168
bufio.(*Reader).fill(0x109000c0)
C:/Go/src/bufio/bufio.go:97 +0xf4
bufio.(*Reader).ReadSlice(0x109000c0, 0xa, 0x0, 0x8d, 0x5e4dff9c, 0x0, 0x0)
C:/Go/src/bufio/bufio.go:338 +0x9c
bufio.(*Reader).ReadLine(0x109000c0, 0x8, 0x9, 0x0, 0x0, 0x80, 0x7d30c)
C:/Go/src/bufio/bufio.go:367 +0x24
net/textproto.(*Reader).readLineSlice(0x10810ec0, 0x0, 0x1f8b40, 0x1f8b54, 0x80, 0x332160)
C:/Go/src/net/textproto/reader.go:55 +0x44
net/textproto.(*Reader).ReadLine(0x10810ec0, 0x108acd80, 0x80000000, 0x0, 0x80000000)
C:/Go/src/net/textproto/reader.go:36 +0x1c
net/http.readRequest(0x109000c0, 0x0, 0x108acd80, 0x0, 0x0)
C:/Go/src/net/http/request.go:918 +0x5c
net/http.(*conn).readRequest(0x1089f6e0, 0x4a36e8, 0x10811240, 0x0, 0x0, 0x0)
C:/Go/src/net/http/server.go:934 +0x214
net/http.(*conn).serve(0x1089f6e0, 0x4a36e8, 0x10811240)
C:/Go/src/net/http/server.go:1763 +0x3b4
created by net/http.(*Server).Serve
C:/Go/src/net/http/server.go:2668 +0x234
goroutine 52 [IO wait]:
net.runtime_pollWait(0x76da2d98, 0x72, 0x10917000)
C:/Go/src/runtime/netpoll.go:164 +0x44
net.(*pollDesc).wait(0x108165bc, 0x72, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_poll_runtime.go:75 +0x28
net.(*pollDesc).waitRead(0x108165bc, 0x10917000, 0x1000)
C:/Go/src/net/fd_poll_runtime.go:80 +0x24
net.(*netFD).Read(0x10816580, 0x10917000, 0x1000, 0x1000, 0x0, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_unix.go:250 +0x148
net.(*conn).Read(0x108787a0, 0x10917000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
C:/Go/src/net/net.go:181 +0x58
net/http.(*connReader).Read(0x10896d20, 0x10917000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
C:/Go/src/net/http/server.go:754 +0x168
bufio.(*Reader).fill(0x10896810)
C:/Go/src/bufio/bufio.go:97 +0xf4
bufio.(*Reader).ReadSlice(0x10896810, 0xa, 0x0, 0x8d, 0x1e9f4, 0x0, 0x0)
C:/Go/src/bufio/bufio.go:338 +0x9c
bufio.(*Reader).ReadLine(0x10896810, 0x14, 0x9, 0x10811300, 0x0, 0x80, 0x10850000)
C:/Go/src/bufio/bufio.go:367 +0x24
net/textproto.(*Reader).readLineSlice(0x10811300, 0x10811300, 0x1f8b40, 0x1f8b54, 0x80, 0x332160)
C:/Go/src/net/textproto/reader.go:55 +0x44
net/textproto.(*Reader).ReadLine(0x10811300, 0x108ace00, 0x80000000, 0x0, 0x80000000)
C:/Go/src/net/textproto/reader.go:36 +0x1c
net/http.readRequest(0x10896810, 0x0, 0x108ace00, 0x0, 0x0)
C:/Go/src/net/http/request.go:918 +0x5c
net/http.(*conn).readRequest(0x1089f740, 0x4a36e8, 0x108112e0, 0x0, 0x0, 0x0)
C:/Go/src/net/http/server.go:934 +0x214
net/http.(*conn).serve(0x1089f740, 0x4a36e8, 0x108112e0)
C:/Go/src/net/http/server.go:1763 +0x3b4
created by net/http.(*Server).Serve
C:/Go/src/net/http/server.go:2668 +0x234
goroutine 54 [IO wait]:
net.runtime_pollWait(0x76da2e88, 0x72, 0x1089678d)
C:/Go/src/runtime/netpoll.go:164 +0x44
net.(*pollDesc).wait(0x108faf7c, 0x72, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_poll_runtime.go:75 +0x28
net.(*pollDesc).waitRead(0x108faf7c, 0x1089678d, 0x1)
C:/Go/src/net/fd_poll_runtime.go:80 +0x24
net.(*netFD).Read(0x108faf40, 0x1089678d, 0x1, 0x1, 0x0, 0x4a1938, 0x4a00e4)
C:/Go/src/net/fd_unix.go:250 +0x148
net.(*conn).Read(0x10878638, 0x1089678d, 0x1, 0x1, 0x0, 0x0, 0x0)
C:/Go/src/net/net.go:181 +0x58
net/http.(*connReader).backgroundRead(0x10896780)
C:/Go/src/net/http/server.go:656 +0x44
created by net/http.(*connReader).startBackgroundRead
C:/Go/src/net/http/server.go:652 +0xd4
Profile:
goroutine profile: total 7
2 @ 0x3d008 0x38354 0x377d8 0x135f14 0x135f64 0x1373ec 0x146b64 0x1fd88c 0x6c15c
0x377d7 net.runtime_pollWait+0x43 C:/Go/src/runtime/netpoll.go:164
0x135f13 net.(*pollDesc).wait+0x27 C:/Go/src/net/fd_poll_runtime.go:75
0x135f63 net.(*pollDesc).waitRead+0x23 C:/Go/src/net/fd_poll_runtime.go:80
0x1373eb net.(*netFD).Read+0x147 C:/Go/src/net/fd_unix.go:250
0x146b63 net.(*conn).Read+0x57 C:/Go/src/net/net.go:181
0x1fd88b net/http.(*connReader).backgroundRead+0x43 C:/Go/src/net/http/server.go:656
2 @ 0x3d008 0x38354 0x377d8 0x135f14 0x135f64 0x1373ec 0x146b64 0x1fddb4 0xfd5c4 0xfe3e8 0xfe5c0 0x1a024c 0x1a00c4 0x1f8b68 0x1fedfc 0x202b18 0x6c15c
0x377d7 net.runtime_pollWait+0x43 C:/Go/src/runtime/netpoll.go:164
0x135f13 net.(*pollDesc).wait+0x27 C:/Go/src/net/fd_poll_runtime.go:75
0x135f63 net.(*pollDesc).waitRead+0x23 C:/Go/src/net/fd_poll_runtime.go:80
0x1373eb net.(*netFD).Read+0x147 C:/Go/src/net/fd_unix.go:250
0x146b63 net.(*conn).Read+0x57 C:/Go/src/net/net.go:181
0x1fddb3 net/http.(*connReader).Read+0x167 C:/Go/src/net/http/server.go:754
0xfd5c3 bufio.(*Reader).fill+0xf3 C:/Go/src/bufio/bufio.go:97
0xfe3e7 bufio.(*Reader).ReadSlice+0x9b C:/Go/src/bufio/bufio.go:338
0xfe5bf bufio.(*Reader).ReadLine+0x23 C:/Go/src/bufio/bufio.go:367
0x1a024b net/textproto.(*Reader).readLineSlice+0x43 C:/Go/src/net/textproto/reader.go:55
0x1a00c3 net/textproto.(*Reader).ReadLine+0x1b C:/Go/src/net/textproto/reader.go:36
0x1f8b67 net/http.readRequest+0x5b C:/Go/src/net/http/request.go:918
0x1fedfb net/http.(*conn).readRequest+0x213 C:/Go/src/net/http/server.go:934
0x202b17 net/http.(*conn).serve+0x3b3 C:/Go/src/net/http/server.go:1763
1 @ 0x2ade84 0x2adcdc 0x2aacb4 0x2b0cb4 0x2b0f1c 0x204094 0x20502c 0x205f84 0x202c8c 0x6c15c
0x2ade83 runtime/pprof.writeRuntimeProfile+0x77 C:/Go/src/runtime/pprof/pprof.go:632
0x2adcdb runtime/pprof.writeGoroutine+0x73 C:/Go/src/runtime/pprof/pprof.go:594
0x2aacb3 runtime/pprof.(*Profile).WriteTo+0x2af C:/Go/src/runtime/pprof/pprof.go:302
0x2b0cb3 net/http/pprof.handler.ServeHTTP+0x167 C:/Go/src/net/http/pprof/pprof.go:209
0x2b0f1b net/http/pprof.Index+0x17b C:/Go/src/net/http/pprof/pprof.go:221
0x204093 net/http.HandlerFunc.ServeHTTP+0x33 C:/Go/src/net/http/server.go:1942
0x20502b net/http.(*ServeMux).ServeHTTP+0x107 C:/Go/src/net/http/server.go:2238
0x205f83 net/http.serverHandler.ServeHTTP+0x7b C:/Go/src/net/http/server.go:2568
0x202c8b net/http.(*conn).serve+0x527 C:/Go/src/net/http/server.go:1825
1 @ 0x3d008 0x38354 0x377d8 0x135f14 0x135f64 0x138684 0x150238 0x14e860 0x207364 0x206324 0x2060a4 0x206ca0 0x2b11fc 0x3cbc0 0x6c15c
0x377d7 net.runtime_pollWait+0x43 C:/Go/src/runtime/netpoll.go:164
0x135f13 net.(*pollDesc).wait+0x27 C:/Go/src/net/fd_poll_runtime.go:75
0x135f63 net.(*pollDesc).waitRead+0x23 C:/Go/src/net/fd_poll_runtime.go:80
0x138683 net.(*netFD).accept+0x15b C:/Go/src/net/fd_unix.go:430
0x150237 net.(*TCPListener).accept+0x1f C:/Go/src/net/tcpsock_posix.go:136
0x14e85f net.(*TCPListener).AcceptTCP+0x3b C:/Go/src/net/tcpsock.go:215
0x207363 net/http.tcpKeepAliveListener.Accept+0x1b C:/Go/src/net/http/server.go:3044
0x206323 net/http.(*Server).Serve+0x1ab C:/Go/src/net/http/server.go:2643
0x2060a3 net/http.(*Server).ListenAndServe+0x8f C:/Go/src/net/http/server.go:2585
0x206c9f net/http.ListenAndServe+0x6f C:/Go/src/net/http/server.go:2787
0x2b11fb main.main+0x67 e:/gopath/src/ttt/ws/ws.go:21
0x3cbbf runtime.main+0x1e3 C:/Go/src/runtime/proc.go:185
1 @ 0x3d008 0x3d0d0 0x4da58 0x7cbf8 0x1fda64 0x1fc098 0x203b14 0x241c28 0x242cbc 0x2b147c 0x204094 0x20502c 0x205f84 0x202c8c 0x6c15c
0x4da57 sync.runtime_notifyListWait+0x137 C:/Go/src/runtime/sema.go:297
0x7cbf7 sync.(*Cond).Wait+0x77 C:/Go/src/sync/cond.go:57
0x1fda63 net/http.(*connReader).abortPendingRead+0xbb C:/Go/src/net/http/server.go:686
0x1fc097 net/http.(*conn).hijackLocked+0x2b C:/Go/src/net/http/server.go:292
0x203b13 net/http.(*response).Hijack+0xb7 C:/Go/src/net/http/server.go:1892
0x241c27 github.com/gorilla/websocket.(*Upgrader).Upgrade+0x313 e:/gopath/src/github.com/gorilla/websocket/server.go:164
0x242cbb github.com/gorilla/websocket.Upgrade+0x67 e:/gopath/src/github.com/gorilla/websocket/server.go:269
0x2b147b main.wsHandler+0xab e:/gopath/src/ttt/ws/ws.go:38
0x204093 net/http.HandlerFunc.ServeHTTP+0x33 C:/Go/src/net/http/server.go:1942
0x20502b net/http.(*ServeMux).ServeHTTP+0x107 C:/Go/src/net/http/server.go:2238
0x205f83 net/http.serverHandler.ServeHTTP+0x7b C:/Go/src/net/http/server.go:2568
0x202c8b net/http.(*conn).serve+0x527 C:/Go/src/net/http/server.go:1825
HEAP:
heap profile: 1: 16 [1: 16] @ heap/1048576
1: 16 [1: 16] @ 0x1b8c18 0x1b89e4 0x1ba7e4 0x21a100 0x2b178c 0x3cb74 0x6c15c
0x1b8c17 vendor/golang_org/x/net/http2/hpack.addDecoderNode+0x1f3 C:/Go/src/vendor/golang_org/x/net/http2/hpack/huffman.go:144
0x1b89e3 vendor/golang_org/x/net/http2/hpack.init.1+0x6f C:/Go/src/vendor/golang_org/x/net/http2/hpack/huffman.go:127
0x1ba7e3 vendor/golang_org/x/net/http2/hpack.init+0x158f C:/Go/src/vendor/golang_org/x/net/http2/hpack/tables.go:353
0x21a0ff net/http.init+0xb3 C:/Go/src/net/http/transport.go:2184
0x2b178b main.init+0x47 e:/gopath/src/ttt/ws/ws.go:63
0x3cb73 runtime.main+0x197 C:/Go/src/runtime/proc.go:173
0: 0 [0: 0] @ 0x2ac4b4 0x2aacb4 0x2b0cb4 0x2b0f1c 0x204094 0x20502c 0x205f84 0x202c8c 0x6c15c
0x2ac4b3 runtime/pprof.writeHeap+0x63 C:/Go/src/runtime/pprof/pprof.go:489
0x2aacb3 runtime/pprof.(*Profile).WriteTo+0x2af C:/Go/src/runtime/pprof/pprof.go:302
0x2b0cb3 net/http/pprof.handler.ServeHTTP+0x167 C:/Go/src/net/http/pprof/pprof.go:209
0x2b0f1b net/http/pprof.Index+0x17b C:/Go/src/net/http/pprof/pprof.go:221
0x204093 net/http.HandlerFunc.ServeHTTP+0x33 C:/Go/src/net/http/server.go:1942
0x20502b net/http.(*ServeMux).ServeHTTP+0x107 C:/Go/src/net/http/server.go:2238
0x205f83 net/http.serverHandler.ServeHTTP+0x7b C:/Go/src/net/http/server.go:2568
0x202c8b net/http.(*conn).serve+0x527 C:/Go/src/net/http/server.go:1825
runtime.MemStats
Alloc = 417584
TotalAlloc = 417584
Sys = 21568636
Lookups = 17
Mallocs = 6452
Frees = 396
HeapAlloc = 417584
HeapSys = 1703936
HeapIdle = 688128
HeapInuse = 1015808
HeapReleased = 0
HeapObjects = 6056
Stack = 393216 / 393216
MSpan = 10856 / 16384
MCache = 2400 / 16384
BuckHashSys = 722973
GCSys = 17501184
OtherSys = 1214559
NextGC = 4473924
PauseNs = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
NumGC = 0
DebugGC = false