mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Owin: set HttpListener.IgnoreWriteExceptions = true
This commit is contained in:
@@ -17,6 +17,7 @@ using System.Web.Http.Tracing;
|
|||||||
using Jackett.Utils;
|
using Jackett.Utils;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using System.Web.Http.ExceptionHandling;
|
using System.Web.Http.ExceptionHandling;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
[assembly: OwinStartup(typeof(Startup))]
|
[assembly: OwinStartup(typeof(Startup))]
|
||||||
namespace Jackett
|
namespace Jackett
|
||||||
@@ -82,6 +83,23 @@ namespace Jackett
|
|||||||
// Configure Web API for self-host.
|
// Configure Web API for self-host.
|
||||||
var config = new HttpConfiguration();
|
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>();
|
appBuilder.Use<WebApiRootRedirectMiddleware>();
|
||||||
|
|
||||||
// register exception handler
|
// register exception handler
|
||||||
|
Reference in New Issue
Block a user