I am running WebApi based on Owin Selfhost, where I introduced the API error handler without processing through
config.Services.Add(typeof(IExceptionLogger), _apiExceptionLogger);
Relevant part of ApiExceptionLogger:
public override void Log(ExceptionLoggerContext context) { if (context == null || context.ExceptionContext == null) return; Logger.Error("Unhandled exception from Web API", context.ExceptionContext.Exception); }
The cases that he catches and register regularly are those where the client requests a dataset, and then closes the connection, while the results (JSON) are sent back - people make a request in chrome, and then press the X button until all results return: P
I pasted the stack below for completeness, I just want to know two things:
- Is this regular / expected behavior? AFAIK is ... I am running a fairly standard API and pipeline
- Is there any way to handle this? Essentially, processing a stop request is more elegant in the case of a cancellation (cancellation tokens peered across the request pipeline come to mind, but do not look like they do a lot in this case, after all tokens support only joint cancellation )
I did not dive deep into the sequence of events occurring at the socket level, as long as this is just unsatisfactory logging.
System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException ---> System.Net.HttpListenerException: The I/O operation has been aborted because of either a thread exit or an application request at System.Net.HttpResponseStream.EndWrite(IAsyncResult asyncResult) at Microsoft.Owin.Host.HttpListener.RequestProcessing.ExceptionFilterStream.EndWrite(IAsyncResult asyncResult) --- End of inner exception stack trace --- at Microsoft.Owin.Host.HttpListener.RequestProcessing.ExceptionFilterStream.EndWrite(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of inner exception stack trace --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Owin.HttpMessageHandlerAdapter.<SendResponseContentAsync>d__20.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Owin.HttpMessageHandlerAdapter.<SendResponseContentAsync>d__20.MoveNext()
Vivek
source share