programing

원격 호스트가 연결을 종료했습니다.

nasanasas 2020. 10. 17. 10:37
반응형

원격 호스트가 연결을 종료했습니다. 오류 코드는 0x800704CD입니다.


예외가 발생할 때마다 내 웹 사이트에서 오류 이메일을받습니다. 이 오류가 발생합니다.

원격 호스트가 연결을 종료했습니다. 오류 코드는 0x800704CD입니다.

이유를 모릅니다. 나는 하루에 약 30 개를받습니다. 오류를 재현 할 수 없으므로 문제를 추적 할 수 없습니다.

웹 사이트는 IIS7에서 실행되는 ASP.NET 2입니다.

스택 추적 :

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.HttpResponse.Flush ( ) at System.Web.HttpResponse.End () at System.Web.UI.HttpResponseWrapper.System.Web.UI.IHttpResponse.End () at System.Web.UI.PageRequestManager.OnPageError (Object sender, EventArgs e) at System .Web.UI.TemplateControl.OnError (EventArgs e) 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.ASP.default_aspx.ProcessRequest (HttpContext 컨텍스트)의 System.Web.UI.Page.ProcessRequest (HttpContext 컨텍스트)에서 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute ()의 ProcessRequestWithNoAssert (HttpContext 컨텍스트) System.Web.HttpApplication.ExecuteStep (IExecutionStep 단계, Boolean & completedSynchronously)


나는 항상 이것을 얻는다. 사용자가 파일 다운로드를 시작한 후 실패 했거나 취소 했음을 의미 합니다.

예외를 재현하려면 직접 시도해보십시오. 그러나이를 방지 할 수있는 방법이 없습니다 (이 특정 예외 처리 만 제외).

앱에 따라 최선의 방법을 결정해야합니다.


마찬가지로 m.edmondson 언급 "원격 호스트에 연결을 종료." 사용자 또는 브라우저가 무언가를 취소 하거나 네트워크 연결이 끊어 질 때 발생합니다 . 파일 다운로드 일 필요는 없지만 클라이언트에 응답하는 모든 리소스에 대한 요청 일뿐입니다. 기본적으로 오류는 서버가 더 이상 클라이언트 (브라우저)와 통신 할 수 없기 때문에 응답을 보낼 수 없음을 의미합니다.

이를 막기 위해 취할 수있는 여러 단계가 있습니다. Response.Write, Response.Flush를 사용하여 응답에서 무언가를 수동으로 보내고 웹 서비스 / 페이지 메서드 또는 이와 유사한 것에서 데이터를 반환하는 경우 응답을 보내기 전에 Response.IsClientConnected를 확인하는 것이 좋습니다. 또한 응답 시간이 오래 걸리거나 서버 측 처리가 많이 필요한 경우 response.end가 호출 될 때까지 주기적으로이를 확인해야합니다. 이 속성에 대한 자세한 내용은 다음을 참조하십시오.

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

또는 귀하의 경우에 가장 가능성이 있다고 생각하는 오류는 프레임 워크 내부의 무언가로 인해 발생합니다. 다음 링크를 사용할 수 있습니다.

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

다음 스택 오버플로 게시물도 유용 할 수 있습니다.

Response.OutputStream.Write의 "원격 호스트가 연결을 닫았습니다."


아래 코드로 오류를 재현 할 수 있습니다.

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();
} 

이제 웹 사이트를 디버그 모드로 실행하십시오. 출력 스트림에 쓰는 루프에 중단 점을 넣으십시오. 해당 작업 방법으로 이동하고 첫 번째 반복이 통과 된 후 브라우저의 탭을 닫습니다. 루프를 계속하려면 F10을 누르십시오. 다음 반복에 도달하면 예외가 표시됩니다. 예외를 즐기십시오 :-)


I was getting this on an asp.net 2.0 iis7 Windows2008 site. Same code on iis6 worked fine. It was causing an issue for me because it was messing up the login process. User would login and get a 302 to default.asxp, which would get through page_load, but not as far as pre-render before iis7 would send a 302 back to login.aspx without the auth cookie. I started playing with app pool settings, and for some reason 'enable 32 bit applications' seems to have fixed it. No idea why, since this site isn't doing anything special that should require any 32 bit drivers. We have some sites that still use Access that require 32bit, but not our straight SQL sites like this one.


I got this error when I dynamically read data from a WebRequest and never closed the 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;
    }

I too got this same error on my image handler that I wrote. I got it like 30 times a day on site with heavy traffic, managed to reproduce it also. You get this when a user cancels the request (closes the page or his internet connection is interrupted for example), in my case in the following row:

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

I can’t think of any way to prevent it but maybe you can properly handle this. Ex:

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

참고URL : https://stackoverflow.com/questions/5564862/the-remote-host-closed-the-connection-the-error-code-is-0x800704cd

반응형