NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.16k stars 1.47k forks source link

Nancy.Selfhost sometimes throws HttpListenerException, Nancy on top of OWIN does not #2629

Open mvacha opened 7 years ago

mvacha commented 7 years ago

Description

I made a windows service on top of TopShelf and deployed it into production. Under production load (10s of clients sending requests to the service every few seconds) there were HttpListenerException exception every few seconds in the log. Changing Nancy.Selfhost to Owin (with Katana webserver) resolved the issue.

Exception detail

2016-11-21 16:39:32.761 +01:00 [Error] Unhandled exception in NancyFX: AggregateException { InnerExceptions: [HttpListenerException { ErrorCode: 995, NativeErrorCode: 995, Message: "The I/O operation has been aborted because of either a thread exit or an application request", Data: [], InnerException: null, TargetSite: Int32 EndRead(System.IAsyncResult), StackTrace: " at System.Net.HttpRequestStream.EndRead(IAsyncResult asyncResult) at Nancy.Extensions.StreamExtensions.<>c__DisplayClass3.<CopyTo>b__1(IAsyncResult readResult)", HelpLink: null, Source: "System", HResult: -2147467259 }], Message: "One or more errors occurred.", Data: [], InnerException: HttpListenerException { ErrorCode: 995, NativeErrorCode: 995, Message: "The I/O operation has been aborted because of either a thread exit or an application request", Data: [], InnerException: null, TargetSite: Int32 EndRead(System.IAsyncResult), StackTrace: " at System.Net.HttpRequestStream.EndRead(IAsyncResult asyncResult) at Nancy.Extensions.StreamExtensions.<>c__DisplayClass3.<CopyTo>b__1(IAsyncResult readResult)", HelpLink: null, Source: "System", HResult: -2147467259 }, TargetSite: Void ThrowIfExceptional(Boolean), StackTrace: " at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Nancy.IO.RequestStream..ctor(Stream stream, Int64 expectedLength, Int64 thresholdLength, Boolean disableStreamSwitching) at Nancy.Hosting.Self.NancyHost.ConvertRequestToNancyRequest(HttpListenerRequest request) at Nancy.Hosting.Self.NancyHost.Process(HttpListenerContext ctx)", HelpLink: null, Source: "mscorlib", HResult: -2146233088 }

System Configuration

damianh commented 7 years ago

Thanks for reporting this. We're 50/50 on maintaining the selfhost given there is OwinHttpListener and OwinWebListenerHost option.

mvacha commented 7 years ago

Sure, it makes sense to focus on the core features and leave the rest to others. The project mentioned is already in production and Katana+Owin+Nancy works perfectly.