Owin: set HttpListener.IgnoreWriteExceptions = true

This commit is contained in:
kaso17
2017-01-25 18:40:40 +01:00
parent 88c865e8c9
commit d071f19654

View File

@@ -17,6 +17,7 @@ using System.Web.Http.Tracing;
using Jackett.Utils;
using Microsoft.AspNet.Identity;
using System.Web.Http.ExceptionHandling;
using System.Net;
[assembly: OwinStartup(typeof(Startup))]
namespace Jackett
@@ -82,6 +83,23 @@ namespace Jackett
// Configure Web API for self-host.
var config = new HttpConfiguration();
// try to fix SocketException crashes
// based on http://stackoverflow.com/questions/23368885/signalr-owin-self-host-on-linux-mono-socketexception-when-clients-lose-connectio/30583109#30583109
try
{
object httpListener;
if (appBuilder.Properties.TryGetValue(typeof(HttpListener).FullName, out httpListener) && httpListener is HttpListener)
{
// HttpListener should not return exceptions that occur when sending the response to the client
((HttpListener)httpListener).IgnoreWriteExceptions = true;
Engine.Logger.Info("set HttpListener.IgnoreWriteExceptions = true");
}
}
catch (Exception e)
{
Engine.Logger.Error(e, "Error while setting HttpListener.IgnoreWriteExceptions = true");
}
appBuilder.Use<WebApiRootRedirectMiddleware>();
// register exception handler