You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/05/28 03:07:55 UTC
[3/6] guacamole-client git commit: GUACAMOLE-567: Add UNSTABLE tunnel
status. Mark tunnel as UNSTABLE if no data has been received in a reasonable
amount of time, but the tunnel is technically still open.
GUACAMOLE-567: Add UNSTABLE tunnel status. Mark tunnel as UNSTABLE if no data has been received in a reasonable amount of time, but the tunnel is technically still open.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/e6f36659
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/e6f36659
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/e6f36659
Branch: refs/heads/master
Commit: e6f36659954653271495ee2c12cd80469a2ee63a
Parents: ca98d07
Author: Michael Jumper <mj...@apache.org>
Authored: Sun Dec 10 20:22:22 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Sun May 27 15:43:41 2018 -0700
----------------------------------------------------------------------
.../src/main/webapp/modules/Tunnel.js | 75 ++++++++++++++++++--
1 file changed, 69 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/e6f36659/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 63e27c5..52bd20a 100644
--- a/guacamole-common-js/src/main/webapp/modules/Tunnel.js
+++ b/guacamole-common-js/src/main/webapp/modules/Tunnel.js
@@ -84,12 +84,23 @@ Guacamole.Tunnel = function() {
* The maximum amount of time to wait for data to be received, in
* milliseconds. If data is not received within this amount of time,
* the tunnel is closed with an error. The default value is 15000.
- *
+ *
* @type {Number}
*/
this.receiveTimeout = 15000;
/**
+ * The amount of time to wait for data to be received before considering
+ * the connection to be unstable, in milliseconds. If data is not received
+ * within this amount of time, the tunnel status is updated to warn that
+ * the connection appears unresponsive and may close. The default value is
+ * 1500.
+ *
+ * @type {Number}
+ */
+ this.unstableThreshold = 1500;
+
+ /**
* The UUID uniquely identifying this tunnel. If not yet known, this will
* be null.
*
@@ -165,7 +176,15 @@ Guacamole.Tunnel.State = {
*
* @type {Number}
*/
- "CLOSED": 2
+ "CLOSED": 2,
+
+ /**
+ * The connection is open, but communication through the tunnel appears to
+ * be disrupted, and the connection may close as a result.
+ *
+ * @type {Number}
+ */
+ "UNSTABLE" : 3
};
@@ -220,6 +239,14 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
var receive_timeout = null;
/**
+ * The current connection stability timeout ID, if any.
+ *
+ * @private
+ * @type {Number}
+ */
+ var unstableTimeout = null;
+
+ /**
* Additional headers to be sent in tunnel requests. This dictionary can be
* populated with key/value header pairs to pass information such as authentication
* tokens, etc.
@@ -253,14 +280,24 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
*/
function reset_timeout() {
- // Get rid of old timeout (if any)
+ // Get rid of old timeouts (if any)
window.clearTimeout(receive_timeout);
+ window.clearTimeout(unstableTimeout);
+
+ // Clear unstable status
+ if (tunnel.state === Guacamole.Tunnel.State.UNSTABLE)
+ tunnel.setState(Guacamole.Tunnel.State.OPEN);
- // Set new timeout
+ // Set new timeout for tracking overall connection timeout
receive_timeout = window.setTimeout(function () {
close_tunnel(new Guacamole.Status(Guacamole.Status.Code.UPSTREAM_TIMEOUT, "Server timeout."));
}, tunnel.receiveTimeout);
+ // Set new timeout for tracking suspected connection instability
+ unstableTimeout = window.setTimeout(function() {
+ tunnel.setState(Guacamole.Tunnel.State.UNSTABLE);
+ }, tunnel.unstableThreshold);
+
}
/**
@@ -274,6 +311,10 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
*/
function close_tunnel(status) {
+ // Get rid of old timeouts (if any)
+ window.clearTimeout(receive_timeout);
+ window.clearTimeout(unstableTimeout);
+
// Ignore if already closed
if (tunnel.state === Guacamole.Tunnel.State.CLOSED)
return;
@@ -683,6 +724,14 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
var receive_timeout = null;
/**
+ * The current connection stability timeout ID, if any.
+ *
+ * @private
+ * @type {Number}
+ */
+ var unstableTimeout = null;
+
+ /**
* The WebSocket protocol corresponding to the protocol used for the current
* location.
* @private
@@ -733,14 +782,24 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
*/
function reset_timeout() {
- // Get rid of old timeout (if any)
+ // Get rid of old timeouts (if any)
window.clearTimeout(receive_timeout);
+ window.clearTimeout(unstableTimeout);
+
+ // Clear unstable status
+ if (tunnel.state === Guacamole.Tunnel.State.UNSTABLE)
+ tunnel.setState(Guacamole.Tunnel.State.OPEN);
- // Set new timeout
+ // Set new timeout for tracking overall connection timeout
receive_timeout = window.setTimeout(function () {
close_tunnel(new Guacamole.Status(Guacamole.Status.Code.UPSTREAM_TIMEOUT, "Server timeout."));
}, tunnel.receiveTimeout);
+ // Set new timeout for tracking suspected connection instability
+ unstableTimeout = window.setTimeout(function() {
+ tunnel.setState(Guacamole.Tunnel.State.UNSTABLE);
+ }, tunnel.unstableThreshold);
+
}
/**
@@ -754,6 +813,10 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
*/
function close_tunnel(status) {
+ // Get rid of old timeouts (if any)
+ window.clearTimeout(receive_timeout);
+ window.clearTimeout(unstableTimeout);
+
// Ignore if already closed
if (tunnel.state === Guacamole.Tunnel.State.CLOSED)
return;