The remote host closed the connection Error, how fix?
Asked Answered
P

5

25

i am using elmah -> Elmah.axd in my project for finding errors.
there is an error like this :

System.Web.HttpException: The remote host closed the connection. The error code is 0x800703E3.
Generated: Sun, 27 Nov 2011 13:06:13 GMT

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Web.HttpException (0x800703E3): The remote host closed the connection. The error code is 0x800703E3.
   at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
   at System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()
   at System.Web.HttpResponse.Flush(Boolean finalFlush)
   at System.Web.HttpWriter.TransmitFile(String filename, Int64 offset, Int64 size, Boolean isImpersonating, Boolean supportsLongTransmitFile)
   at System.Web.HttpResponse.TransmitFile(String filename, Int64 offset, Int64 length)
   at SalarSoft.Utility.SP1.ResumeDownload.ProcessDownload(String fileName, String headerFileName)
   at NiceFileExplorer.en.Download.DownloadFile_SalarSoft(String fileName)
   at NiceFileExplorer.en.Download.GoForDownloadFile(String filepath)
   at NiceFileExplorer.en.Download.MainCodes()
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.HandleError(Exception e)
   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.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

during working with web site, we do n't see this error.
but elmah send this error to me many many times.
what this error mean and how can i fix it?

EDIT 1
{my web site is for downlaod mobile files and some times it's really busy}
{i am using windows server 2008 r2-> remote access}

EDIT 2 after comment
some of windows information and warnings (there is no error) logs for today are like below :

warning

A process serving application pool 'ASP.NET 4.0 (Integrated)' exceeded time limits during shut down. The process id was '6764'.

warning

A worker process '3232' serving application pool 'ASP.NET 4.0 (Integrated)' failed to stop a listener channel for protocol 'http' in the allotted time. The data field contains the error number.

warning

A process serving application pool 'ASP.NET 4.0 (Integrated)' exceeded time limits during shut down. The process id was '3928'.

Polymer answered 27/11, 2011 at 13:52 Comment(5)
You need to find out why the remote host is closing the connection.Revers
You would have to look on the server. The Windows Event log on the server, for instance; maybe the IIS log.Revers
@John Saunders hi and thanks for comment, plz see my EDIT 2.Polymer
it seems windows log does not show those errors.why?Polymer
It might not show the exceptions if the server eats them: try{...}catch{}. Also, try turning on ASP.NET Health Monitoring on the server.Revers
A
39

I see this a lot in the logs of a website I built.

AFAIK that exception means that the client broke the connection (went to another page / closed the browser) before the page had finished loading. If the client is downloading a file this error is even more likely as they have more time to decide to quit / move on.

The error is not visible to the users* - so I have just removed it from the Elmah logs.

*The site allows only authenticated users. I can see from Elmah who experienced the error and when. I've asked the users and not one person has ever reported experiencing this bug in the client.

Assist answered 27/11, 2011 at 16:35 Comment(2)
@NeilThompson, were you able to hide this kind of error on Elmah?Bolte
@Bolte yep. I think I used ErrorFiltering. See code.google.com/p/elmah/wiki/ErrorFilteringAssist
V
7

I came across that error when user cancelled file download. On the server side it produces an Exception with message The remote host closed the connection. The error code is 0x800703E3. However, the exception does not have any distinct type that can be handled separately.

In odrer to handle it in ASP.NET MVC properly I added an exception logger:

public static class RegisterFilters
{
    public static void Execute(HttpConfiguration configuration)
    {
        configuration.Services.Add(typeof(IExceptionLogger), new WebExceptionLogger());
    }
}

And WebExceptionLogger class implementation:

public class WebExceptionLogger : ExceptionLogger
{
    private const int RequestCancelledByUserExceptionCode = -2147023901;

    public override void Log(ExceptionLoggerContext context)
    {
        var dependencyScope = context.Request.GetDependencyScope();
        var loggerFactory = dependencyScope.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
        if (loggerFactory == null)
        {
            throw new IoCResolutionException<ILoggerFactory>();
        }

        var logger = loggerFactory.GetTechnicalLogger<WebExceptionLogger>();
        if (context.Exception.HResult == RequestCancelledByUserExceptionCode)
        {
            logger.Info($"Request to url {context.Request.RequestUri} was cancelled by user.");
        }
        else
        {
            logger.Error("An unhandled exception has occured", context.Exception);
        }
    }
}

I noticed that this specifict error type has HResult = -2147023901, so this is what I'm filtering by.

Hope this helps.

Virnelli answered 2/1, 2018 at 12:32 Comment(1)
Documentation on HResult -2147023901 and 0x800703E3 hresult.info/FACILITY_WIN32/0x800703E3Commissar
A
3

I ran into this today, and for me, it was happening because the socket timed out waiting for the remote side to send.

In this example, an extremely (or deliberately) slow client might cause the exception.

I chose to resolve it by increasing the receive timeout on my sockets, since I wanted to support a few specific slower clients that were taxed with the high SSL requirements.

Archdeaconry answered 15/11, 2013 at 1:57 Comment(0)
M
1

Bit late to this party, but in case it helps others, Response.Close() was causing the exception in my situation.

I was seeing the exception, described by the OP, captured by Elmah.

This was occurring due to closing the response (the code I was supporting was writing to the Response output stream):

Response.Flush();
Response.Close();
Response.End();

Removing Response.Close(); stopped the exception being thrown.

Morven answered 12/7, 2017 at 11:51 Comment(0)
B
0

i have faced this problem in MINERGATE /socket_error_the_remote_host_closed_the_connection/ you must sign out and go to C:\Users\yourName\AppData\Local\minergate.ethash-minergate and then delete all files in this folder. good lu

Beckibeckie answered 11/8, 2018 at 7:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.