diff --git a/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs b/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs index cf4396edf..35499eacd 100644 --- a/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs +++ b/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Host.Owin.MiddleWare { SignalrDependencyResolver.Register(container); - GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(300000); + GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromMinutes(3); } public void Attach(IAppBuilder appBuilder) diff --git a/src/UI/Shared/Messenger.js b/src/UI/Shared/Messenger.js index ab53a619a..04823f984 100644 --- a/src/UI/Shared/Messenger.js +++ b/src/UI/Shared/Messenger.js @@ -23,12 +23,13 @@ define(function () { } } - return window.Messenger().post({ + return window.Messenger().post({ message : options.message, type : options.type, showCloseButton: true, hideAfter : options.hideAfter, - id : options.id + id : options.id, + actions : options.actions }); }, diff --git a/src/UI/Shared/SignalRBroadcaster.js b/src/UI/Shared/SignalRBroadcaster.js index 55b0c2b31..88ab7d3c8 100644 --- a/src/UI/Shared/SignalRBroadcaster.js +++ b/src/UI/Shared/SignalRBroadcaster.js @@ -3,8 +3,9 @@ define( [ 'vent', 'jquery', + 'Shared/Messenger', 'signalR' - ], function (vent, $) { + ], function (vent, $, Messenger) { return { appInitializer: function () { @@ -25,6 +26,9 @@ define( } }; + var tryingToReconnect = false; + var messengerId = 'signalR'; + this.signalRconnection = $.connection('/signalr'); this.signalRconnection.stateChanged(function (change) { @@ -35,6 +39,49 @@ define( vent.trigger('server:' + message.name, message.body); }); + this.signalRconnection.reconnecting(function() { + tryingToReconnect = true; + + Messenger.show({ + id : messengerId, + type : 'info', + hideAfter : 0, + message : 'Connection to backend lost, attempting to reconnect' + }); + }); + + this.signalRconnection.reconnected(function() { + tryingToReconnect = false; + + Messenger.show({ + id : messengerId, + type : 'success', + hideAfter : 5, + message : 'Connection to backend restored' + }); + }); + + this.signalRconnection.disconnected(function () { + if (tryingToReconnect) { + $('
').appendTo(document.body); + + Messenger.show({ + id : messengerId, + type : 'error', + hideAfter : 0, + message : 'Connection to backend lost', + actions : { + cancel: { + label: 'Reload', + action: function() { + window.location.reload(); + } + } + } + }); + } + }); + this.signalRconnection.start({ transport: [ 'longPolling'