diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 162b3967c4..9e21bd11fa 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -652,7 +652,9 @@ var tower = angular.module('Tower', [ if($rootScope.dashboardInterval){ window.clearInterval($rootScope.dashboardInterval); } - sock.socket.socket.disconnect(); + if (sock) { + sock.socket.socket.disconnect(); + } $location.path('/login'); } } else { diff --git a/awx/ui/static/js/shared/Socket.js b/awx/ui/static/js/shared/Socket.js index 63285175fe..13b31fb432 100644 --- a/awx/ui/static/js/shared/Socket.js +++ b/awx/ui/static/js/shared/Socket.js @@ -100,8 +100,15 @@ angular.module('SocketIO', ['AuthService', 'Utilities']) }); }); self.socket.on('connect_failed', function(reason) { - var r = reason || 'connection refused by host'; - $log.error('Socket connection failed: ' + r); + var r = reason || 'connection refused by host', + token_actual = Authorization.getToken(); + + $log.debug('Socket connection failed: ' + r); + + if (token_actual === token) { + self.socket.socket.disconnect(); + } + self.scope.$apply(function () { self.scope.socketStatus = 'error'; self.scope.socketTip = getSocketTip(self.scope.socketStatus);