mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
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.
This commit is contained in:
@@ -84,11 +84,22 @@ Guacamole.Tunnel = function() {
|
|||||||
* The maximum amount of time to wait for data to be received, in
|
* The maximum amount of time to wait for data to be received, in
|
||||||
* milliseconds. If data is not received within this amount of time,
|
* milliseconds. If data is not received within this amount of time,
|
||||||
* the tunnel is closed with an error. The default value is 15000.
|
* the tunnel is closed with an error. The default value is 15000.
|
||||||
*
|
*
|
||||||
* @type {Number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
this.receiveTimeout = 15000;
|
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
|
* The UUID uniquely identifying this tunnel. If not yet known, this will
|
||||||
* be null.
|
* be null.
|
||||||
@@ -165,7 +176,15 @@ Guacamole.Tunnel.State = {
|
|||||||
*
|
*
|
||||||
* @type {Number}
|
* @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
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -219,6 +238,14 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
|
|||||||
*/
|
*/
|
||||||
var receive_timeout = null;
|
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
|
* Additional headers to be sent in tunnel requests. This dictionary can be
|
||||||
* populated with key/value header pairs to pass information such as authentication
|
* populated with key/value header pairs to pass information such as authentication
|
||||||
@@ -253,14 +280,24 @@ Guacamole.HTTPTunnel = function(tunnelURL, crossDomain, extraTunnelHeaders) {
|
|||||||
*/
|
*/
|
||||||
function reset_timeout() {
|
function reset_timeout() {
|
||||||
|
|
||||||
// Get rid of old timeout (if any)
|
// Get rid of old timeouts (if any)
|
||||||
window.clearTimeout(receive_timeout);
|
window.clearTimeout(receive_timeout);
|
||||||
|
window.clearTimeout(unstableTimeout);
|
||||||
|
|
||||||
// Set new timeout
|
// Clear unstable status
|
||||||
|
if (tunnel.state === Guacamole.Tunnel.State.UNSTABLE)
|
||||||
|
tunnel.setState(Guacamole.Tunnel.State.OPEN);
|
||||||
|
|
||||||
|
// Set new timeout for tracking overall connection timeout
|
||||||
receive_timeout = window.setTimeout(function () {
|
receive_timeout = window.setTimeout(function () {
|
||||||
close_tunnel(new Guacamole.Status(Guacamole.Status.Code.UPSTREAM_TIMEOUT, "Server timeout."));
|
close_tunnel(new Guacamole.Status(Guacamole.Status.Code.UPSTREAM_TIMEOUT, "Server timeout."));
|
||||||
}, tunnel.receiveTimeout);
|
}, 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) {
|
function close_tunnel(status) {
|
||||||
|
|
||||||
|
// Get rid of old timeouts (if any)
|
||||||
|
window.clearTimeout(receive_timeout);
|
||||||
|
window.clearTimeout(unstableTimeout);
|
||||||
|
|
||||||
// Ignore if already closed
|
// Ignore if already closed
|
||||||
if (tunnel.state === Guacamole.Tunnel.State.CLOSED)
|
if (tunnel.state === Guacamole.Tunnel.State.CLOSED)
|
||||||
return;
|
return;
|
||||||
@@ -682,6 +723,14 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
|
|||||||
*/
|
*/
|
||||||
var receive_timeout = null;
|
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
|
* The WebSocket protocol corresponding to the protocol used for the current
|
||||||
* location.
|
* location.
|
||||||
@@ -733,14 +782,24 @@ Guacamole.WebSocketTunnel = function(tunnelURL) {
|
|||||||
*/
|
*/
|
||||||
function reset_timeout() {
|
function reset_timeout() {
|
||||||
|
|
||||||
// Get rid of old timeout (if any)
|
// Get rid of old timeouts (if any)
|
||||||
window.clearTimeout(receive_timeout);
|
window.clearTimeout(receive_timeout);
|
||||||
|
window.clearTimeout(unstableTimeout);
|
||||||
|
|
||||||
// Set new timeout
|
// Clear unstable status
|
||||||
|
if (tunnel.state === Guacamole.Tunnel.State.UNSTABLE)
|
||||||
|
tunnel.setState(Guacamole.Tunnel.State.OPEN);
|
||||||
|
|
||||||
|
// Set new timeout for tracking overall connection timeout
|
||||||
receive_timeout = window.setTimeout(function () {
|
receive_timeout = window.setTimeout(function () {
|
||||||
close_tunnel(new Guacamole.Status(Guacamole.Status.Code.UPSTREAM_TIMEOUT, "Server timeout."));
|
close_tunnel(new Guacamole.Status(Guacamole.Status.Code.UPSTREAM_TIMEOUT, "Server timeout."));
|
||||||
}, tunnel.receiveTimeout);
|
}, 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) {
|
function close_tunnel(status) {
|
||||||
|
|
||||||
|
// Get rid of old timeouts (if any)
|
||||||
|
window.clearTimeout(receive_timeout);
|
||||||
|
window.clearTimeout(unstableTimeout);
|
||||||
|
|
||||||
// Ignore if already closed
|
// Ignore if already closed
|
||||||
if (tunnel.state === Guacamole.Tunnel.State.CLOSED)
|
if (tunnel.state === Guacamole.Tunnel.State.CLOSED)
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user