3

I am using latest version of WebAPI. My WebAPI return RSS feed data. I did a load testing with blitz and below are its results.

This rush generated 115,908 successful hits in 300 seconds and we transferred 1.91 GB of data in and out of your app. The average hit rate of 386.36/second translates to about 33,381,504 hits/day. The average response time was 410 ms. You've got bigger problems, though: 0.87% of the users during this rush experienced timeouts or errors!

The Code for WebAPI which returns RSS is as below. It uses OutPutCache lib from https://github.com/filipw/AspNetWebApi-OutputCache

[AllowAnonymous]
        [CacheOutput(ServerTimeSpan = 14400)]
        [HttpGet]
        public async Task<HttpResponseMessage> GetRssData()
        {

            string responseFromServer = string.Empty;
            WebRequest request = WebRequest.Create("URL FOR MY RSS FEED HERE");


            using (WebResponse response = await request.GetResponseAsync())
            {
                using (Stream dataStream = response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(dataStream))
                    {
                        responseFromServer = await reader.ReadToEndAsync();
                    }
                }
            }

            return new HttpResponseMessage() { Content = new StringContent(responseFromServer, Encoding.UTF8, "application/rss+xml") };

        }

Below is the error log for same

Exception information: Exception type: OperationCanceledException Exception message: The operation was canceled. at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at System.Web.Http.WebHost.HttpControllerHandler.d__1b.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.WebHost.HttpControllerHandler.d__7.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.WebHost.HttpControllerHandler.d__0.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.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)

Thread information:

Stack trace:    at System.Threading.CancellationToken.ThrowIfCancellationRequested()   

at System.Web.Http.WebHost.HttpControllerHandler.d__1b.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.WebHost.HttpControllerHandler.d__7.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.WebHost.HttpControllerHandler.d__0.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.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)

NoobDeveloper
  • 1,877
  • 6
  • 30
  • 55

1 Answers1

1

This looks like cancelled requests, being automatically cancelled by Web API. You can typically ignore these errors (and they will not show up on global error handling starting with Web API 5.2).

Yishai Galatzer
  • 8,791
  • 2
  • 32
  • 41
  • I have 5.2.2.0 and I still get these nasty errors every time I cancel ajax request. This sucks – Toolkit Sep 14 '14 at 13:13
  • 1
    @Toolkit, we don't know of a scenario where what you describe actually happens. It will be very useful if you can open an issue and upload a repro project in aspnetwebstack.codeplex.com Can you be specific about what exception you are getting? If it's `TaskCancelledException` you can safely ignore it, but we really want to see the scenario. – Yishai Galatzer Sep 15 '14 at 14:52
  • 1
    @Toolkit can you also let us know if you are using an exception filter or the IExceptionHandler/IExceptionFilter – Yishai Galatzer Sep 15 '14 at 16:40
  • I solved it by ignoring this type of errors. see my answer http://stackoverflow.com/a/25990396/631527 I am encountering when I need to do instant search and I need to cancel previous ajax request, so it doesn't overlap with the next one – Toolkit Sep 23 '14 at 09:11
  • 1
    Ah, note that there are two exception handling mechanisms in Web API. Your answer refers to exception filters, who always react to TaskCancelledException. The user is asking about Exception Loggers and GlobalExceptionHandlers that filter them out. Exception filters wrap an action execution, while the other two report everywhere an exception is thrown in user code or framework code (even if the framework will swallow the exception by default). So looks like your answer is valid, just for a different question :) – Yishai Galatzer Sep 23 '14 at 15:50