gpt4 book ai didi

asp.net-mvc - 操作被取消。在 System.Threading.CancellationToken.ThrowIfCancellationRequested()

转载 作者:行者123 更新时间:2023-12-04 18:07:25 25 4
gpt4 key购买 nike

我正在使用最新版本的 WebAPI。我的 WebAPI 返回 RSS 提要数据。我用 blitz 做了一个负载测试,下面是它的结果。

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!

返回 RSS 的 WebAPI 代码如下。它使用来自 https://github.com/filipw/AspNetWebApi-OutputCache 的 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") };

}

下面是同样的错误日志

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)

最佳答案

这看起来像是已取消的请求,被 Web API 自动取消。您通常可以忽略这些错误(从 Web API 5.2 开始,它们不会出现在全局错误处理中)。

关于asp.net-mvc - 操作被取消。在 System.Threading.CancellationToken.ThrowIfCancellationRequested(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23460293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com