The remote host has closed the connection. Error Code: 0x800704CD

I get error messages from my site whenever an exception occurs. I get this error:

The remote host has closed the connection. Error Code: 0x800704CD

and I don’t know why. I get about 30 a day. I can not reproduce the error, so I can not track the problem.

The ASP.NET 2 website runs on IIS7.

Stack trace:

in System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError (Int32 result, Boolean throwOnDisconnect) when System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush () in System.Web.HttpResponse.Flush (BooHlefll final ) at System.Web.HttpResponse.End () at System.Web.UI.HttpResponseWrapper.System.Web.UI.IHttpResponse.End () in System.Web.UI.PageRequestManager.OnPageError (Sender Object, EventArgs e) in System .Web.UI.TemplateControl.OnError (EventArgs is System.Web.UI.Page.HandleError (Exception is System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) in System.Web.UIPest.Page.pest.pest process Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) in System.Web.UI.Page.ProcessRequest () in System.Web.UI.Page.ProcessRequestWithNoAssert (HttpContext context) in System.Web.UI.Page.PttCestCest AS (Context) P.default_aspx.ProcessRequest (HttpContext context) in System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute () in System.Web.HttpApplication.ExecuteStep (IExecutionStep) completed

+56
iis-7
Apr 6 2018-11-11T00:
source share
6 answers

I get it all the time. This means that the user started downloading the file, and then either failed or they were canceled .

To reproduce the exception, try to do it yourself - however, I don’t know about any ways to prevent it (except for handling only this particular exception).

You need to decide what is the best way to move forward depending on your application.

+49
Apr 6 2018-11-11T00:
source share

As M. Edmondson mentioned, "the remote host has closed the connection." happens when a user or browser cancels something, or the network connection drops, etc. However, it does not have to be a file download, but only any request for any resource that gives an answer to the client. Basically, an error means that the answer cannot be sent, because the server can no longer talk to the client (browser).

There are several steps you can take to stop this. If you manually send something in response with Response.Write, Response.Flush, return data from the web servivce / page method or something like that, then you should consider checking Response.IsClientConnected before sending a response. Also, if the response is likely to take a long time or requires a lot of server-side processing, you should check it periodically until response.end is called. For more information about this property, see the following:

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.isclientconnected.aspx

As an alternative, most likely, in your case, the error occurs due to something inside the frame. The following link can be used:

http://blog.whitesites.com/fixing-The-remote-host-closed-the-connection-The-error-code-is-0x80070057__633882307305519259_blog.htm

The following post might also be interesting:

"Remote host closed the connection" in Response.OutputStream.Write

+20
Mar 08 2018-12-12T00:
source share

You can reproduce the error using the code below:

public ActionResult ClosingTheConnectionAction(){ try { //we need to set buffer to false to //make sure data is written in chunks Response.Buffer = false; var someText = "Some text here to make things happen ;-)"; var content = GetBytes( someText ); for(var i=0; i < 100; i++) { Response.OutputStream.Write(content, 0, content.Length); } return View(); } catch(HttpException hex) { if (hex.Message.StartsWith("The remote host closed the connection. The error code is 0x800704CD.")) { //react on remote host closed the connection exception. var msg = hex.Message; } } catch(Exception somethingElseHappened) { //handle it with some other code } return View(); } 

Now run the website in debug mode. Place a breakpoint in the loop that writes to the output stream. Go to this method of action and after the first iteration has passed closing the browser tab. Press F10 to continue the cycle. After clicking the next iteration, you will see an exception. Enjoy your exception :-)

+7
Mar 26 '15 at 15:14
source share

I was getting this on the asp.net 2.0 iis7 Windows2008 website. The same code on iis6 worked fine. This caused a problem for me because it ruined the login process. The user must log in and get 302 by default .asxp, which will go through page_load, but not before rendering, before iis7 sends 302 back to login.aspx without an auth cookie. I started playing with application pool settings, and for some reason, "enable 32-bit applications" seems to have fixed it. I do not know why, since this site does not do anything special, which should require any 32-bit drivers. We have some sites that still use Access, which require 32-bit, but not our direct SQL sites like this.

+1
Sep 20 '11 at 18:46
source share

I got this error when I dynamically read data with WebRequest and never closed Response .

  protected System.IO.Stream GetStream(string url) { try { System.IO.Stream stream = null; var request = System.Net.WebRequest.Create(url); var response = request.GetResponse(); if (response != null) { stream = response.GetResponseStream(); // I never closed the response thus resulting in the error response.Close(); } response = null; request = null; return stream; } catch (Exception) { } return null; } 
+1
Feb 26 '13 at 15:19
source share

I also had the same error for my image processor that I wrote. I got it as 30 times a day in a place with heavy traffic, I managed to reproduce it as well. You get this when the user cancels the request (closes the page or his Internet connection is interrupted, for example), in my case, in the following line:

 myContext.Response.OutputStream.Write(buffer, 0, bytesRead); 

I can't think about preventing this, but maybe you can handle it. Example:

  try { … myContext.Response.OutputStream.Write(buffer, 0, bytesRead); … }catch (HttpException ex) { if (ex.Message.StartsWith("The remote host closed the connection.")) ;//do nothing else //handle other errors } catch (Exception e) { //handle other errors } finally {//close streams etc.. } 
+1
Nov 04 '13 at 7:59
source share



All Articles