GUACAMOLE-431: Fix tunnel stuck in CLOSED state

When the tunnel is closed and another `connect()` call is made, it stops
notifying about state changes (`onstatechanges`) if the connection continues
to fail.

This patch sets the state to `CONNECTING` when calling `connect()`.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/63f603ec
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/63f603ec
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/63f603ec

Branch: refs/heads/master
Commit: 63f603ec9dfe91e33f4de83f27b6a81e1992c13a
Parents: d778ad7
Author: Or Cohen <o...@strigo.io>
Authored: Tue Nov 7 11:47:57 2017 +0200
Committer: Or Cohen <o...@strigo.io>
Committed: Tue Nov 7 12:41:51 2017 +0200

----------------------------------------------------------------------
 guacamole-common-js/src/main/webapp/modules/Tunnel.js | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/63f603ec/guacamole-common-js/src/main/webapp/modules/Tunnel.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Tunnel.js 
b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
index 3fa6ef7..2b1826d 100644
--- a/guacamole-common-js/src/main/webapp/modules/Tunnel.js
+++ b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
@@ -564,6 +564,9 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain) {
         // Start waiting for connect
         reset_timeout();
 
+        // Mark the tunnel as connecting
+        tunnel.setState(Guacamole.Tunnel.State.CONNECTING);
+
         // Start tunnel and connect
         var connect_xmlhttprequest = new XMLHttpRequest();
         connect_xmlhttprequest.onreadystatechange = function() {
@@ -760,6 +763,9 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
 
         reset_timeout();
 
+        // Mark the tunnel as connecting
+        tunnel.setState(Guacamole.Tunnel.State.CONNECTING);
+
         // Connect socket
         socket = new WebSocket(tunnelURL + "?" + data, "guacamole");
 

Reply via email to