diff --git a/src/websocket-client.ts b/src/websocket-client.ts index ade0eeb0..e8f0d5e1 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -808,11 +808,11 @@ export class WebsocketClient extends EventEmitter { const wasOpen = this.wsStore.isWsOpen(wsKey); - this.getWs(wsKey)?.terminate(); - delete this.wsStore.get(wsKey, true).activePongTimer; this.clearPingTimer(wsKey); this.clearPongTimer(wsKey); + this.getWs(wsKey)?.terminate(); + if (!wasOpen) { this.logger.info( `${reason} - socket already closed - trigger immediate reconnect`,