From f6a29ddeeb5557d8f20f998038a065d04509fd9d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 30 Jul 2015 10:13:35 -0400 Subject: [PATCH] Fix occasional error with sending while readyState !== 1 Under certain conditions, noVNC would attempt to flush the web socket while it was disconnected, before the disconnected state was picked up. This casues noVNC to crash ungracefully and the parent window is not notified - leading to no chance at recovery without a page refresh. --- include/websock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/websock.js b/include/websock.js index f3336a0a..4d7a4f9a 100644 --- a/include/websock.js +++ b/include/websock.js @@ -197,7 +197,7 @@ function Websock() { } if (this._websocket.bufferedAmount < this.maxBufferedAmount) { - if (this._sQlen > 0) { + if (this._sQlen > 0 && this._websocket.readyState === WebSocket.OPEN) { this._websocket.send(this._encode_message()); this._sQlen = 0; }