We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Listen() seems to spawn a goroutine for reading websocket messages.
However, when the websocket is closed, the goroutine sometimes fails with this panic error.
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0xc8 pc=0xa44116] goroutine 2753 [running]: github.com/gorilla/websocket.(*Conn).NextReader(0x0, 0xc00000ed28, 0xc000419f40, 0x404de5, 0xc00053e420, 0xc000419f90) C:/Users/Tyrone/go/src/github.com/gorilla/websocket/conn.go:936 +0x26 github.com/gorilla/websocket.(*Conn).ReadMessage(0x0, 0xc000419f90, 0xc0003cac00, 0x331, 0x600, 0x0, 0x0) C:/Users/Tyrone/go/src/github.com/gorilla/websocket/conn.go:1026 +0x2f github.com/proximax-storage/go-xpx-catapult-sdk/sdk/websocket.(*CatapultWebsocketClientImpl).Listen.func1(0xc000375900, 0xc00053e420) C:/Users/Tyrone/go/src/github.com/proximax-storage/go-xpx-catapult-sdk/sdk/websocket/client.go:132 +0x116 created by github.com/proximax-storage/go-xpx-catapult-sdk/sdk/websocket.(*CatapultWebsocketClientImpl).Listen C:/Users/Tyrone/go/src/github.com/proximax-storage/go-xpx-catapult-sdk/sdk/websocket/client.go:127 +0x98
My understanding is due to the setting of conn to nil as shown on the line below.
conn
nil
for { select { case <-c.ctx.Done(): if c.conn != nil { if err := c.conn.Close(); err != nil { panic(err) } c.conn = nil } return case msg := <-messagesChan: go c.messageRouter.RouteMessage(msg) } }
Can we remove the c.conn = nil to avoid panic?
c.conn = nil
For some reason, I can't replicate on a simple code the issue but on the app it always happens. The removal of above fixed my proble.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Listen() seems to spawn a goroutine for reading websocket messages.
However, when the websocket is closed, the goroutine sometimes fails with this panic error.
My understanding is due to the setting of
conn
tonil
as shown on the line below.Can we remove the
c.conn = nil
to avoid panic?For some reason, I can't replicate on a simple code the issue but on the app it always happens. The removal of above fixed my proble.
The text was updated successfully, but these errors were encountered: