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()`.
@@ -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");
