可能导致“客户端已断开连接”的原因 ASP.NET 异常?

发布于 2024-07-18 14:57:51 字数 168 浏览 5 评论 0原文

我的 .NET 3.5 应用程序偶尔会引发以下异常 System.Web 异常:

客户端已断开连接

为什么会出现这个异常? 我的应用程序正在负载平衡的 Windows Server 2003 IIS 6.0 服务器上运行。

My .NET 3.5 application sporadically throws the following exception System.Web exception:

The client disconnected

Why is this exception occurring? My application is running on a load balanced Windows Server 2003 IIS 6.0 server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

若水微香 2024-07-25 14:57:51

vbdork.net 域现在似乎已不复存在。 在搜索这个错误时,我发现了这篇文章的几个参考文献。 所以我找到了它的谷歌缓存版本,现在将其发布在这里以供参考。 原始网址为: http://vbdork.net/post/ 2009/02/10/The-client-disconnected.aspx

您收到消息客户端已断开连接。

如果您位于网络场中并且有一个用户可以进行多项选择的页面,则可能会偶尔收到此错误消息,通常会发生在以下情况中:

用户选择了一个包含回发事件的下拉列表框,但用户在请求发送回用户之前再次执行此操作,用户现在正在创建在其他网络服务器上触发的第二个事件,前一个 Web 服务器尝试将旧事件的结果返回给用户,但该用户已不再存在,因为该用户现在位于另一个 Web 服务器上。

用户永远不会看到错误,但如果您发现错误并通过电子邮件发送/记录它们,您会看到如下所示的错误,并感到非常沮丧。 不用担心,忽略它就不是问题,只要你捕获这种错误就不会出错。

类型:System.Web.HttpException、System.Web、Version=2.0.0.0、Culture=neutral、PublicKeyToken=b03f5f7f11d50a3a 
  消息:客户端已断开连接。 
  来源:System.Web 
  帮助链接: 
  错误代码:-2147467259 
  数据:System.Collections.ListDictionaryInternal 
  TargetSite:Void ThrowError(System.Exception,System.String,System.String,Boolean) 
  堆栈跟踪:在 System.Web.UI.ViewStateException.ThrowError(异常内部,字符串 persistedState,字符串 errorPageMes​​sage,布尔 macValidationError) 
             在 System.Web.UI.HiddenFieldPageStatePersister.Load() 
             在 System.Web.UI.Page.LoadPageStateFromPersistenceMedium() 
             在 System.Web.UI.Page.LoadAllState() 
             在 System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,布尔 includeStagesAfterAsyncPoint) 
             在 System.Web.UI.Page.ProcessRequest(布尔 includeStagesBeforeAsyncPoint,布尔 includeStagesAfterAsyncPoint) 
             在 System.Web.UI.Page.ProcessRequest() 
             在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext 上下文) 
             在 System.Web.UI.Page.ProcessRequest(HttpContext 上下文) 
             在 ASP.src_rptprefs_chainhierarchy_aspx.ProcessRequest(HttpContext 上下文) 
             在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
             在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,Boolean&completedSynchronously) 

          内部异常 
          ---------------- 
          类型:System.Web.UI.ViewStateException、System.Web、版本=2.0.0.0、文化=中性、PublicKeyToken=b03f5f7f11d50a3a 
          消息:视图状态无效。 

  客户端IP:10.21.4.8 
  端口:46784 
  用户代理:Mozilla/4.0(兼容;MSIE 6.0;Windows NT 5.1;SV1;InfoPath.1;.NET CLR 1.1.4322;MS-RTC LM 8) 
  

The vbdork.net domain seems to now be defunct. In searching on this error, I found several references to this article. So I found a google cached version of it and am now posting it here for reference. The original URL was: http://vbdork.net/post/2009/02/10/The-client-disconnected.aspx

You get the message The client Disconnected.

You're likely to sporadically get this error message if you're in a web farm and you have a page where the user can make multiple selections, it typically happens in this scenario:

The user selects a drop down list box that has an event on postback, but the user does this again before the request is sent back to the user, the user is now creating a second event that is being fired on the other webserver, the previous webserver tries to return the results of the old event to the user but the user is no longer there because the user is now on the other webserver.

The user will never see an error, but if you're catching the errors and emailing/logging them you'll see them like shown below and be totally frustrated. Don't worry about it, just ignore it it's not even an problem, as long as you're trapping this kind of error nothing will go wrong.

Type : System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Message : The client disconnected.
Source : System.Web
Help link :
ErrorCode : -2147467259
Data : System.Collections.ListDictionaryInternal
TargetSite : Void ThrowError(System.Exception, System.String, System.String, Boolean)
Stack Trace :    at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
           at System.Web.UI.HiddenFieldPageStatePersister.Load()
           at System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
           at System.Web.UI.Page.LoadAllState()
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
           at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
           at System.Web.UI.Page.ProcessRequest()
           at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
           at System.Web.UI.Page.ProcessRequest(HttpContext context)
           at ASP.src_rptprefs_chainhierarchy_aspx.ProcessRequest(HttpContext context)
           at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
           at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

        Inner Exception
        ---------------
        Type : System.Web.UI.ViewStateException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
        Message : Invalid viewstate.

Client IP: 10.21.4.8
Port: 46784
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 1.1.4322; MS-RTC LM 8)
謸气贵蔟 2024-07-25 14:57:51

也许是因为“客户端已断开连接”...

关闭浏览器,导航到新页面,厌倦了等待应用程序加载...

严肃地说,请查看 此页面 有关该问题的大量信息。

总之,发生这种情况是因为浏览器正在发起一个新请求,该请求会在第一个服务器处理原始请求时退回到第二个服务器。 他的建议是忽略它。

我的建议是弄清楚为什么您的负载均衡器没有在后续请求中将客户端固定到同一服务器; 也称为“粘性”会话。

Perhaps because the "client disconnected"...

Closed browser, navigating to a new page, tired of waiting for the app to load...

In all seriousness, check out this page for a lot of information on that problem.

In summary it's happening because the browser is initiating a new request that bounces to the second server while the first server is processing the original request. His advice is to simply ignore it.

My advice would be to figure out why your load balancer isn't keeping the client tacked to the same server on subsequent requests; also called "Sticky" sessions.

逆蝶 2024-07-25 14:57:51

如果您使用 Telerik 组件,请删除 RadCompression 模块。

If you are using Telerik components, get rid of RadCompression module.

彻夜缠绵 2024-07-25 14:57:51

另请查看有关类似问题的此答案。 在这种情况下就没有网络农场。

ViewState变得“大”并且用户在上一个请求完成之前单击按钮时,会引发此异常。 [...] 这种情况很容易发生,因为回发使用的是 ajax,因此在将 ViewState 发送到服务器时浏览器不会停止响应。

感谢 Russell Clarvoe

Also check out this answer on a similar question. There is no web farm in that case.

This exception is thrown when the ViewState has become "large" and the user clicks a button before a previous request has completed. [...] This happens very easily because the post back is using ajax, so the browser doesn't stop responding while the ViewState is being sent to the server.

Credit to Russell Clarvoe

最单纯的乌龟 2024-07-25 14:57:51

尝试通过使用 web.config 中的 maxPageStateFieldLength 将视图状态分块为多个字段来修复:

<pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" validateRequest="false" maxPageStateFieldLength="20">

attempt to fix by chunking the viewstate into multiple fields using maxPageStateFieldLength in the web.config:

<pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" validateRequest="false" maxPageStateFieldLength="20">
红焚 2024-07-25 14:57:51

其他可能的原因:
您使用的控件实际上不支持 Ajax。
Ajax 应该能够处理异步请求,但某些控件不起作用,例如 telerik (ajax) 树视图。
(像往常一样,等待 Telerik 网络警察来审查这种不良宣传。)

Other likely causes:
You're using controls that do not support Ajax in reality.
Ajax is supposed to be able to handle async requests, but some controls don't work, such as the telerik (ajax) treeview.
(Awaiting the telerik internet police to come censor this bad publicity, as usual.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文