Radarr/src/NzbDrone.Host/Owin/MiddleWare/SignalRMiddleWare.cs

35 lines
1.5 KiB
C#
Raw Normal View History

using System;
2013-05-05 21:24:33 +00:00
using Microsoft.AspNet.SignalR;
2013-05-10 23:53:50 +00:00
using NzbDrone.Common.Composition;
using NzbDrone.Common.EnvironmentInfo;
2013-09-11 06:33:47 +00:00
using NzbDrone.SignalR;
using Owin;
2017-01-05 19:42:02 +00:00
namespace Radarr.Host.Owin.MiddleWare
{
public class SignalRMiddleWare : IOwinMiddleWare
{
2016-12-09 06:54:15 +00:00
public int Order => 1;
2013-05-05 21:24:33 +00:00
2013-09-11 06:33:47 +00:00
public SignalRMiddleWare(IContainer container)
{
SignalRDependencyResolver.Register(container);
SignalRJsonSerializer.Register();
// 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)
{
2018-11-23 07:03:32 +00:00
appBuilder.MapSignalR("/signalr", typeof(NzbDronePersistentConnection), new ConnectionConfiguration());
}
}
}