Imgur / incus

incus is a middleware for distributing messages via websockets, long polling, and push notifications
MIT License
361 stars 37 forks source link

Incus crashes on websocket disconnect #58

Open AdriVanHoudt opened 9 years ago

AdriVanHoudt commented 9 years ago

I am trying to get this working with websockets but sometimes during testing when reloading my webpage this happens

2015/08/31 10:17:18 Error: websocket: close 1001 
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x68 pc=0x45e034]

goroutine 21 [running]:
github.com/Imgur/incus.(*RedisStore).MarkInactive(0x0, 0xc20800ada0, 0x5, 0xc20800b0a8, 0x1, 0x0, 0x0)
    /go/src/github.com/Imgur/incus/redis_store.go:211 +0x144
github.com/Imgur/incus.(*Socket).Close(0xc208010310, 0x0, 0x0)
    /go/src/github.com/Imgur/incus/sockets.go:85 +0x111
created by github.com/Imgur/incus.(*Socket).listenForMessages
    /go/src/github.com/Imgur/incus/sockets.go:147 +0x1df

goroutine 1 [IO wait, 2 minutes]:
net.(*pollDesc).Wait(0xc208010610, 0x72, 0x0, 0x0)
    /usr/src/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc208010610, 0x0, 0x0)
    /usr/src/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).accept(0xc2080105b0, 0x0, 0x7f18e9c1abb0, 0xc20800ab30)
    /usr/src/go/src/net/fd_unix.go:419 +0x40b
net.(*TCPListener).AcceptTCP(0xc208038040, 0x482bce, 0x0, 0x0)
    /usr/src/go/src/net/tcpsock_posix.go:234 +0x4e
net/http.tcpKeepAliveListener.Accept(0xc208038040, 0x0, 0x0, 0x0, 0x0)
    /usr/src/go/src/net/http/server.go:1976 +0x4c
net/http.(*Server).Serve(0xc20805c360, 0x7f18e9c1c160, 0xc208038040, 0x0, 0x0)
    /usr/src/go/src/net/http/server.go:1728 +0x92
net/http.(*Server).ListenAndServe(0xc20805c360, 0x0, 0x0)
    /usr/src/go/src/net/http/server.go:1718 +0x154
net/http.ListenAndServe(0xc20800ae60, 0x5, 0x0, 0x0, 0x0, 0x0)
    /usr/src/go/src/net/http/server.go:1808 +0xba
main.listenAndServe(0xc20803ac60)
    /go/src/github.com/Imgur/incus/incus/main.go:71 +0x166
main.main()
    /go/src/github.com/Imgur/incus/incus/main.go:66 +0x51e

goroutine 5 [syscall, 8 minutes]:
os/signal.loop()
    /usr/src/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
    /usr/src/go/src/os/signal/signal_unix.go:27 +0x35

goroutine 6 [chan send, 2 minutes]:
github.com/Imgur/incus.func·015()
    /go/src/github.com/Imgur/incus/sockets.go:25 +0x13a
created by github.com/Imgur/incus.init·1
    /go/src/github.com/Imgur/incus/sockets.go:27 +0x5c

goroutine 7 [chan receive, 8 minutes]:
main.func·002()
    /go/src/github.com/Imgur/incus/incus/main.go:92 +0x198
created by main.InstallSignalHandlers
    /go/src/github.com/Imgur/incus/incus/main.go:103 +0x25

goroutine 8 [sleep]:
github.com/Imgur/incus.(*Server).RecordStats(0xc208040460, 0x3b9aca00)
    /go/src/github.com/Imgur/incus/server.go:301 +0x5f
created by main.main
    /go/src/github.com/Imgur/incus/incus/main.go:57 +0x430

goroutine 9 [sleep]:
github.com/Imgur/incus.(*Server).LogConnectedClientsPeriodically(0xc208040460, 0x4a817c800)
    /go/src/github.com/Imgur/incus/server.go:308 +0xff
created by main.main
    /go/src/github.com/Imgur/incus/incus/main.go:58 +0x459

goroutine 20 [select, 2 minutes]:
github.com/Imgur/incus.(*Socket).listenForWrites(0xc208010310)
    /go/src/github.com/Imgur/incus/sockets.go:163 +0x736
created by github.com/Imgur/incus.func·011
    /go/src/github.com/Imgur/incus/server.go:131 +0x9a4

goroutine 14 [sleep]:
github.com/Imgur/incus.(*Server).SendHeartbeatsPeriodically(0xc208040460, 0x4a817c800)
    /go/src/github.com/Imgur/incus/server.go:280 +0x36
created by main.main
    /go/src/github.com/Imgur/incus/incus/main.go:63 +0x4ea

goroutine 18 [select, 2 minutes]:
github.com/Imgur/incus.func·011(0x7f18e9c1c340, 0xc208044320, 0xc208032680)
    /go/src/github.com/Imgur/incus/server.go:133 +0xb4e
net/http.HandlerFunc.ServeHTTP(0xc20800af00, 0x7f18e9c1c340, 0xc208044320, 0xc208032680)
    /usr/src/go/src/net/http/server.go:1265 +0x41
net/http.(*ServeMux).ServeHTTP(0xc20803a6c0, 0x7f18e9c1c340, 0xc208044320, 0xc208032680)
    /usr/src/go/src/net/http/server.go:1541 +0x17d
net/http.serverHandler.ServeHTTP(0xc20805c360, 0x7f18e9c1c340, 0xc208044320, 0xc208032680)
    /usr/src/go/src/net/http/server.go:1703 +0x19a
net/http.(*conn).serve(0xc208044000)
    /usr/src/go/src/net/http/server.go:1204 +0xb57
created by net/http.(*Server).Serve
    /usr/src/go/src/net/http/server.go:1751 +0x35e
briankassouf commented 9 years ago

@jacobgreenleaf This shouldn't be called if Redis is disabled @AdriVanHoudt Can you confirm this happened while REDIS_ENABLED=false?

AdriVanHoudt commented 9 years ago

jup will do some more testing tomorrow to confirm this

AdriVanHoudt commented 9 years ago

can confirm with REDIS_ENABLED=false does not happen when REDIS_ENABLED=true

briankassouf commented 9 years ago

@AdriVanHoudt Thanks for the confirmation!

AdriVanHoudt commented 9 years ago

np, glad to help