websocket: Fix redundant connection monitor error upon disconnect (#1210)

When an existing ws disconnects the connection manager goro will call Connect.
This prevents Connect trying to start another connection manager if it's
already running
This commit is contained in:
Gareth Kirwan
2023-06-05 02:51:43 +01:00
committed by GitHub
parent 400bcb6b56
commit 86a540173d

View File

@@ -261,12 +261,14 @@ func (w *Websocket) Connect() error {
w.setConnectingStatus(false)
w.setInit(true)
err = w.connectionMonitor()
if err != nil {
log.Errorf(log.WebsocketMgr,
"%s cannot start websocket connection monitor %v",
w.GetName(),
err)
if !w.IsConnectionMonitorRunning() {
err = w.connectionMonitor()
if err != nil {
log.Errorf(log.WebsocketMgr,
"%s cannot start websocket connection monitor %v",
w.GetName(),
err)
}
}
subs, err := w.GenerateSubs() // regenerate state on new connection