Sunday, May 5, 2019

OperationCanceledException in ASP.NET Web API 2 application

Hi :) I caught this exception and wrote it to my logs - the issue is I'm not 100% sure why it occurred. Online resources say that it was probably because a client closed the connection before the response could be delivered. Is this common when a client times out?

Uncaught Exception System.OperationCanceledException - The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext() 

For context this is an internal company API that is not under heavy load, but the client and the server are physically quite far away. Also if it helps - the client's timestamp when the request was executed vs the IIS request log shows that there was over 20 second delay (so the client took > 20 seconds to finally send the request). Other successful requests show 1-2 second difference typically.

Any thoughts/hints as to how I can prevent this particular error from occurring in the future (if there is anything on the IIS/ASP.NET side I can fix)?

OperationCanceledException in ASP.NET Web API 2 application Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team