System.OperationCanceLedException:取消操作-Azure webapi
我已经经历了我正在努力的网站突然开始投掷操作CanceLedException。它似乎始于5月25日,没有对网站的已知更改。
有人经历过同样的事情吗?最近的Azure可能会有任何变化吗?任何浏览器的新版本都可以具有这种效果吗(例如,Google Chrome似乎有一些版本约为24-25/5)?
看来仅影响WebApi-endpoints。尚未听到最终用户的任何抱怨,所以我不知道它有多认真,但它以下面的方式显示在日志中。 共同点是,它似乎只会影响Webapi-endpoint(我们以/api/*
为我们)
*2022-06-14T19:00:29,Error,***************,*******,******,0,9760,45,"System.Object : Unhandled Exception at /api/search/autocomplete
System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Net.Http.HttpContentExtensions.<ReadAsAsyncCore>d__17`1.MoveNext()
...omitted some of the stack traces, but it ends with this...
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)",*
I've experienced that the site I'm working on suddenly started to throw OperationalCanceledException. It seems to been started approx 25 May without no known changes to the site.
Does anyone have experienced the same thing? Could it be any changes in Azure lately that could have that effect? could A new version of any browser have that effect (for example Google Chrome seems to have some releases approx 24-25/5)?
It seems only affects webapi-endpoints. Have not heard any complaints from end-users, so I don't know how serious it is, but it shows up in logs as below.
The things in common are that it only seems to affect webapi-endpoints (starting with /api/*
for us)
*2022-06-14T19:00:29,Error,***************,*******,******,0,9760,45,"System.Object : Unhandled Exception at /api/search/autocomplete
System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Net.Http.HttpContentExtensions.<ReadAsAsyncCore>d__17`1.MoveNext()
...omitted some of the stack traces, but it ends with this...
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)",*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
挖掘此问题后,我发现由于API呼叫没有响应,可能会发生例外。
当API呼叫暂停时,问题发生。为避免此问题,您可以更改 httpclient.timeout 。
确保检查您的代码是否需要很长时间才能完成。您必须等待完成该任务。使用
httpclient.timeout
等待完成任务。您可以使用 类中的API中的类别以了解确切问题何时发生/何时发生。
参考
After dig into this issue, I found the exception may occur because of API call doesn't respond.
The issue happens when the API call gets timeout. To avoid this issue, you can change your HttpClient.Timeout.
Make sure to check your code if any of your process taking long to complete. You have to wait for completing that task. Use
HttpClient.Timeout
for wait to complete the task.You can use the OperationCanceledException class in your API to know when/where the exact issue happens.
Reference