Skip to content

Panic in func WebsocketClient.disconnectAndRetry #4

@canselcik

Description

@canselcik

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions