diff options
author | Jose <jose@zeroc.com> | 2016-03-31 21:20:49 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-03-31 21:20:49 +0200 |
commit | 758f6a9b7d831533a1ba5efdd28fd9866e6abea5 (patch) | |
tree | b9a7c950ad2b51c46a868c17a5fe72187da76b38 | |
parent | ICE-7084 - JavaScript Number.isNan not implemented in IE (diff) | |
download | ice-758f6a9b7d831533a1ba5efdd28fd9866e6abea5.tar.bz2 ice-758f6a9b7d831533a1ba5efdd28fd9866e6abea5.tar.xz ice-758f6a9b7d831533a1ba5efdd28fd9866e6abea5.zip |
JavaScript close connection issues:
- ICE-7079 timeout overrides failures with chrome windows wss workers
- ICE-7080 JavaScript uncaught error in WSTransceiver write
-rw-r--r-- | js/src/Ice/browser/WSTransceiver.js | 42 | ||||
-rw-r--r-- | js/test/Ice/timeout/Client.js | 26 |
2 files changed, 33 insertions, 35 deletions
diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js index 5438ea78a66..b4f5d52f268 100644 --- a/js/src/Ice/browser/WSTransceiver.js +++ b/js/src/Ice/browser/WSTransceiver.js @@ -23,6 +23,18 @@ Ice.__M.require(module, ]); var IceSSL = Ice.__M.module("IceSSL"); +// +// With Firefox and Chrome we don't want to close the socket while +// connection is in progress, see comments on close implementation +// below. +// +// We need to check for Edge browser as it include Firefox and Chrome +// in its user agent. +// +var CloseOnConnecting = navigator.userAgent.indexOf("Edge/") !== -1 || + (navigator.userAgent.indexOf("Firefox/") === -1 && + navigator.userAgent.indexOf("Chrome/") === -1); + var Debug = Ice.Debug; var ExUtil = Ice.ExUtil; var Network = Ice.Network; @@ -38,8 +50,6 @@ var StateConnected = 2; var StateClosePending = 3; var StateClosed = 4; -var IsFirefox = navigator.userAgent.indexOf("Firefox") !== -1; - var WSTransceiver = Ice.Class({ __init__: function(instance) { @@ -133,15 +143,18 @@ var WSTransceiver = Ice.Class({ } // - // WORKAROUND: With Firefox, calling close() if the websocket isn't connected - // yet doesn't close the connection. The server doesn't receive any close frame - // and the underlying socket isn't closed causing the server to hang on closing - // the connection until the browser exits. + // With Firefox calling close() if the websocket isn't connected yet + // doesn't close the connection. The server doesn't receive any close + // frame and the underlying socket isn't closed causing the server to + // hang on closing the connection until the browser exits. // - // To workaround this problem, we always wait for the socket to be connected - // or closed before closing the socket. + // With Chrome calling close() the websocket isn't connected yet doesn't + // abort the connection attempt. // - if(this._fd.readyState === WebSocket.CONNECTING && IsFirefox) + // To workaround these problems, we always wait for the socket to be + // connected or closed before closing the socket. + // + if(!CloseOnConnecting && this._fd.readyState === WebSocket.CONNECTING) { this._state = StateClosePending; return; @@ -175,15 +188,20 @@ var WSTransceiver = Ice.Class({ { return true; } - Debug.assert(this._fd); var transceiver = this; var write = function() { - if(transceiver.write(byteBuffer)) + // + // The connection might have been closed. + // + if(transceiver._state !== StateClosed) { - transceiver._bytesWrittenCallback(0, 0); + if(transceiver.write(byteBuffer)) + { + transceiver._bytesWrittenCallback(0, 0); + } } }; diff --git a/js/test/Ice/timeout/Client.js b/js/test/Ice/timeout/Client.js index 77413d7a0cd..533f52560d9 100644 --- a/js/test/Ice/timeout/Client.js +++ b/js/test/Ice/timeout/Client.js @@ -44,7 +44,8 @@ test(obj !== null); mult = 1; - if(communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp") === "ssl") + if(communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp") === "ssl" || + communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp") === "wss") { mult = 4; } @@ -332,26 +333,6 @@ ).then( function() { - // - // Some browsers (Chrome) appear to not cancel the - // connection establishment even of the web socket is - // closed and the next connect succeeds. We perform - // another connection establishment and close the - // connection. - // - return to.ice_getConnection(); - } - ).then( - function(con) - { - con.close(true); - }, - function(ex) - { - } - ).then( - function() - { return timeout.holdAdapter(750 * mult); } ).then( @@ -431,8 +412,7 @@ function() { p.succeed(); - } - ); + }); return p; }; |