2013-09-04 05:02:58 +00:00
|
|
|
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;
|
2019-04-13 03:25:58 +00:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-09-11 06:33:47 +00:00
|
|
|
using NzbDrone.SignalR;
|
2013-05-04 21:09:25 +00:00
|
|
|
using Owin;
|
|
|
|
|
2017-01-05 19:42:02 +00:00
|
|
|
namespace Radarr.Host.Owin.MiddleWare
|
2013-05-04 21:09:25 +00:00
|
|
|
{
|
|
|
|
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)
|
2013-05-04 21:09:25 +00:00
|
|
|
{
|
2018-04-21 05:52:26 +00:00
|
|
|
SignalRDependencyResolver.Register(container);
|
|
|
|
SignalRJsonSerializer.Register();
|
2013-09-04 05:02:58 +00:00
|
|
|
|
2019-07-01 01:50:01 +00:00
|
|
|
// 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);
|
2013-05-04 21:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Attach(IAppBuilder appBuilder)
|
|
|
|
{
|
2018-11-23 07:03:32 +00:00
|
|
|
appBuilder.MapSignalR("/signalr", typeof(NzbDronePersistentConnection), new ConnectionConfiguration());
|
2013-05-04 21:09:25 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-21 05:52:26 +00:00
|
|
|
}
|