Merge pull request #301 from glyptodon/GUAC-1430

GUAC-1430: Fix connection error handling
This commit is contained in:
Mike Jumper
2015-12-09 21:48:27 -08:00
3 changed files with 24 additions and 9 deletions

View File

@@ -884,12 +884,23 @@ Guacamole.ChainedTunnel = function(tunnel_chain) {
/** /**
* Fails the currently-attached tunnel, attaching a new tunnel if * Fails the currently-attached tunnel, attaching a new tunnel if
* possible. * possible.
* *
* @private * @private
* @return {Guacamole.Tunnel} The next tunnel, or null if there are no * @param {Guacamole.Status} [status]
* more tunnels to try. * An object representing the failure that occured in the
* currently-attached tunnel, if known.
*
* @return {Guacamole.Tunnel}
* The next tunnel, or null if there are no more tunnels to try or
* if no more tunnels should be tried.
*/ */
function fail_tunnel() { var failTunnel = function failTunnel(status) {
// Do not attempt to continue using next tunnel on server timeout
if (status && status.code === Guacamole.Status.Code.UPSTREAM_TIMEOUT) {
tunnels = [];
return null;
}
// Get next tunnel // Get next tunnel
var next_tunnel = tunnels.shift(); var next_tunnel = tunnels.shift();
@@ -904,7 +915,7 @@ Guacamole.ChainedTunnel = function(tunnel_chain) {
return next_tunnel; return next_tunnel;
} };
/** /**
* Use the current tunnel from this point forward. Do not try any more * Use the current tunnel from this point forward. Do not try any more
@@ -933,7 +944,7 @@ Guacamole.ChainedTunnel = function(tunnel_chain) {
// If closed, mark failure, attempt next tunnel // If closed, mark failure, attempt next tunnel
case Guacamole.Tunnel.State.CLOSED: case Guacamole.Tunnel.State.CLOSED:
if (!fail_tunnel() && chained_tunnel.onstatechange) if (!failTunnel() && chained_tunnel.onstatechange)
chained_tunnel.onstatechange(state); chained_tunnel.onstatechange(state);
break; break;
@@ -957,7 +968,7 @@ Guacamole.ChainedTunnel = function(tunnel_chain) {
tunnel.onerror = function(status) { tunnel.onerror = function(status) {
// Mark failure, attempt next tunnel // Mark failure, attempt next tunnel
if (!fail_tunnel() && chained_tunnel.onerror) if (!failTunnel(status) && chained_tunnel.onerror)
chained_tunnel.onerror(status); chained_tunnel.onerror(status);
}; };

View File

@@ -155,6 +155,10 @@ angular.module('auth').factory('authenticationService', ['$injector',
// If authentication fails, propogate failure to returned promise // If authentication fails, propogate failure to returned promise
.error(function authenticationFailed(error) { .error(function authenticationFailed(error) {
// Ensure error object exists, even if the error response is not
// coming from the authentication REST endpoint
error = new Error(error);
// Request credentials if provided credentials were invalid // Request credentials if provided credentials were invalid
if (error.type === Error.Type.INVALID_CREDENTIALS) if (error.type === Error.Type.INVALID_CREDENTIALS)
$rootScope.$broadcast('guacInvalidCredentials', parameters, error); $rootScope.$broadcast('guacInvalidCredentials', parameters, error);

View File

@@ -441,8 +441,8 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
// Re-authenticate to verify auth status at end of connection // Re-authenticate to verify auth status at end of connection
authenticationService.updateCurrentToken($location.search()) authenticationService.updateCurrentToken($location.search())
// If authentication is OK, show the requested status // Show the requested status once the authentication check has finished
.then(function authenticationCheckSuccessful() { ['finally'](function authenticationCheckComplete() {
guacNotification.showStatus(status); guacNotification.showStatus(status);
}); });