summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-07-30 10:13:35 -0400
committerSamuel Mannehed <samuel@samuel-xps13.lan>2016-04-30 02:26:17 +0200
commitf6a29ddeeb5557d8f20f998038a065d04509fd9d (patch)
tree8cc4003b675fdb4cb5ed618da0628dfb1e35ca24
parent32df3fdbe1b289b06344902b72537d6dc3671afb (diff)
downloadnovnc-f6a29ddeeb5557d8f20f998038a065d04509fd9d.tar.gz
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.
-rw-r--r--include/websock.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/websock.js b/include/websock.js
index f3336a0..4d7a4f9 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;
}