What might be causing the "The client disconnected" ASP.NET exception?
Asked Answered
F

6

33

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.

Flamboyant answered 30/4, 2009 at 22:25 Comment(1)
Are there inner exceptions like: "Invalid viewstate." and "Invalid length for a Base-64 char array or string."?Glanders
P
32

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)
Pomeranian answered 11/6, 2009 at 12:57 Comment(0)
A
7

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.

Anodyne answered 30/4, 2009 at 22:31 Comment(3)
I had a suspicion about our load balancer, we have been seeing issues in other apps not retaining session variables for users.Flamboyant
note: see Paul Prewett's answer. The link in mine is the same; however, he resurrected the text from that page.Anodyne
Link is dead.. but im still getting this isue with ASP.NEtAdah
P
4

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

Parmesan answered 11/10, 2013 at 11:23 Comment(1)
Can you provide any reference article?Perfidious
I
4

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

Interbrain answered 13/12, 2013 at 16:35 Comment(0)
G
1

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">
Grapher answered 19/7, 2012 at 21:1 Comment(1)
added maxPageStateFieldLength="50" in <Page> tag that worked for meRezzani
L
0

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.)

Loupe answered 15/5, 2013 at 10:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.