客户端断开连接 [英] The client disconnected

查看:108
本文介绍了客户端断开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WebAPI日志中遇到以下错误

I'm getting the following error in logs for WebAPI

System.Web.HttpException(0x800703E3):客户端已断开连接.在System.Web.Hosting.IIS7WorkerRequest.EndRead(IAsyncResult asyncResult)在System.Web.HttpBufferlessInputStream.EndRead(IAsyncResultasyncResult),位于System.Threading.Tasks.TaskFactory1.FromAsyncTrimPromise 1.Complete(TInstance thisRef,Func 3 endMethod,IAsyncResult asyncResult,Boolean requiredSynchronization)---从之前引发异常的位置开始的堆栈跟踪-System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务),位于System.IO.StreamReader.d__97.MoveNext()---从之前引发异常的位置开始的堆栈跟踪-System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)System.IO.StreamReader.d__62.MoveNext()---从上一个引发异常的位置开始的堆栈跟踪---System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)在Microsoft.Owin.OwinRequest.d__0.MoveNext()---从之前引发异常的位置开始的堆栈跟踪-System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__22.MoveNext()---从之前引发异常的位置开始的堆栈跟踪-System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__0.MoveNext()---从之前引发异常的位置开始的堆栈跟踪-System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware1.d__0.MoveNext()---从之前引发异常的位置开始的堆栈跟踪-System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务),网址为:Web.API.Middleware.OwinMiddleware.d__1.MoveNext()在D:\ UAT \ Web.API \ Middleware \ OwinMiddleware.cs:第49行

System.Web.HttpException (0x800703E3): The client disconnected. at System.Web.Hosting.IIS7WorkerRequest.EndRead(IAsyncResult asyncResult) at System.Web.HttpBufferlessInputStream.EndRead(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory 1.FromAsyncTrimPromise 1.Complete(TInstance thisRef, Func 3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.IO.StreamReader.d__97.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.IO.StreamReader.d__62.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Owin.OwinRequest.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware 1.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Web.API.Middleware.OwinMiddleware.d__1.MoveNext() in D:\UAT\Web.API\Middleware\OwinMiddleware.cs:line 49

如何通过异常过滤器处理和忽略这些异常?为什么会发生此错误,我该如何重现该错误?我只想捕获并忽略客户端已断开连接,但不是全部 HttpException

How can I handle and ignore these exceptions by exception filter? Why this error occurs and how can I reproduce that? I wanna catch and ignore only The client disconnected but not all HttpException

我看到了这个类似的问题但是如何在异常过滤器中做到这一点?

I saw this similar question but how can I do that in exception filter?

推荐答案

您可以忽略这些异常.

该异常说明了问题所在:客户端已断开连接".这意味着客户端启动了一个请求,但随后断开了连接,然后才开始读取所有响应.

The exception says what the problem is: "The client disconnected". It means that the client initiated a request but then disconnected before it bothered to read all of the response.

有多种原因可能会导致这种情况,但是(除非您的服务器端互联网连接不稳定),这几乎肯定是客户端的问题.我经常自己看到这些东西,而且大多数情况下似乎与机器人有关.所以我将它们过滤掉并忽略它们.

There are any numbers of reasons why that might be the case, but (unless you have a dodgy internet connection at your server end) it is almost certainly an issue at the client end. I regularly see these myself and mostly it seems to be related to a bot. So I filter them out and ignore them.

这篇关于客户端断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆