diff --git a/lib/websocket-client.js b/lib/websocket-client.js index 9e7672f1..36aeee84 100644 --- a/lib/websocket-client.js +++ b/lib/websocket-client.js @@ -62,7 +62,7 @@ module.exports = class WebsocketClient extends EventEmitter { this.logger.info('Closing connection', {category: 'bybit-ws'}); this.readyState = READY_STATE_CLOSING; this._teardown(); - this.ws.close(); + this.ws && this.ws.close(); } async _connect() {