diff --git a/src/io/ble.js b/src/io/ble.js index 8fa21de2e..c52e069e4 100644 --- a/src/io/ble.js +++ b/src/io/ble.js @@ -73,7 +73,7 @@ class BLE extends JSONRPCWebSocket { * Close the websocket. */ disconnect () { - if (!this._connected) return; + if (this._ws.readyState !== this._ws.OPEN) return; this._ws.close(); this._connected = false; diff --git a/src/io/bt.js b/src/io/bt.js index 455684a2a..1770ec751 100644 --- a/src/io/bt.js +++ b/src/io/bt.js @@ -75,7 +75,7 @@ class BT extends JSONRPCWebSocket { * Close the websocket. */ disconnect () { - if (!this._connected) return; + if (this._ws.readyState !== this._ws.OPEN) return; this._ws.close(); this._connected = false;