Skip to content
New issue

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

Panic in func WebsocketClient.disconnectAndRetry #4

Open
canselcik opened this issue May 17, 2020 · 2 comments
Open

Panic in func WebsocketClient.disconnectAndRetry #4

canselcik opened this issue May 17, 2020 · 2 comments

Comments

@canselcik
Copy link

The library seems to panic on occasion in:

func (w *WebsocketClient) disconnectAndRetry() {
	w.log.Warn("disconnected")
	w.heartbeat.Stop()
	w.conMutex.Lock()
	w.connected = false
	w.conMutex.Unlock()
	w.log.Info("retrying websocket connection in 30s")
	time.Sleep(30 * time.Second)
	w.Restart()
}

at the line w.heartbeat.Stop(). Seems like w.heartbeat can be nil at times.

Patching so that it reads:

if w.heartbeat != nil {
  w.heartbeat.Stop()
}

fixes the panic however w.heartbeat being nil at that time likely points to some other race condition.

@adampointer
Copy link
Owner

Hmm yes I will run the race detector on this.

@0cv
Copy link

0cv commented Feb 7, 2021

Not sure it's related but when simulating a disconnection (as simple as by turning off the wifi), I'm getting a panic when I turn back on the wifi:
image

Edit: the patch above doesn't help

Edit2: socket.Conn is nil, then the seg fault happens. Adding this is enough:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants