diff --git a/frontend/src/Components/SignalRConnector.js b/frontend/src/Components/SignalRConnector.js index 8bcdc3204..308066567 100644 --- a/frontend/src/Components/SignalRConnector.js +++ b/frontend/src/Components/SignalRConnector.js @@ -84,7 +84,7 @@ class SignalRConnector extends Component { constructor(props, context) { super(props, context); - this.signalRconnectionOptions = { transport: ['webSockets', 'longPolling'] }; + this.signalRconnectionOptions = { transport: ['webSockets', 'serverSentEvents', 'longPolling'] }; this.signalRconnection = null; this.retryInterval = 1; this.retryTimeoutId = null; diff --git a/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs b/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs index e3413e1b7..5319474d0 100644 --- a/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs +++ b/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs @@ -16,9 +16,14 @@ namespace NzbDrone.Host.Owin.MiddleWare SignalRDependencyResolver.Register(container); SignalRJsonSerializer.Register(); - // Half the default time (110s) to get under nginx's default 60 proxy_read_timeout - GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(55); - GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromMinutes(3); + // Note there are some important timeouts involved here: + // nginx has a default 60 sec proxy_read_timeout, this means the connection will be terminated if the server doesn't send anything within that time. + // Previously we lowered the ConnectionTimeout from 110s to 55s to remedy that, however all we should've done is set an appropriate KeepAlive. + // By default KeepAlive is 1/3rd of the DisconnectTimeout, which we set incredibly high 5 years ago, resulting in KeepAlive being 1 minute. + // So when adjusting these values in the future, please keep that all in mind. + GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110); + GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(180); + GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(30); } public void Attach(IAppBuilder appBuilder) diff --git a/src/NzbDrone.SignalR/SignalRJsonSerializer.cs b/src/NzbDrone.SignalR/SignalRJsonSerializer.cs index e00b7914a..f86795b90 100644 --- a/src/NzbDrone.SignalR/SignalRJsonSerializer.cs +++ b/src/NzbDrone.SignalR/SignalRJsonSerializer.cs @@ -13,6 +13,7 @@ namespace NzbDrone.SignalR { _serializerSettings = Json.GetSerializerSettings(); _serializerSettings.ContractResolver = new SignalRContractResolver(); + _serializerSettings.Formatting = Formatting.None; // ServerSentEvents doesn't like newlines _serializer = JsonSerializer.Create(_serializerSettings);