2011-11-27 833 views
14

我在我的項目中使用elmah - >Elmah.axd來查找錯誤。
有類似這樣的錯誤:遠程主機關閉連接錯誤,怎麼修復?

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) 

與網站工作的過程中,我們沒有看到這個錯誤。
但elmah多次向我發送此錯誤。
這個錯誤意味着什麼,我該如何解決它?

編輯1
{我的網站是立即下載移動文件和某些時候,它真的很忙}
{我使用的Windows Server 2008 [2->遠程訪問}評論後

EDIT 2
一些窗口的信息和警告(沒有錯誤)今天日誌象下面這樣:

警告

服務應用程序池「ASP.NET 4.0(Integrated)」的進程在關閉期間超過了 時間限制。進程ID是'6764'。

警告

的工作進程 '3232' 服務應用程序池ASP.NET 4.0 (集成)'失敗在 停協議的聽者信道的 'http' 所分配的時間。數據字段包含錯誤編號。

警告

進程服務應用程序池 'ASP.NET 4.0(集成)' 關閉過程中超出 時間限制。進程ID是'3928'。

+0

您需要找出遠程主機關閉連接的原因。 –

+0

你將不得不在服務器上看。例如,服務器上的Windows事件日誌;也許是IIS日誌。 –

+0

@John Saunders嗨,感謝評論,PLZ看到我編輯2. – MoonLight

回答

23

我在我建立的網站的日誌中看到了很多。

AFAIK異常意味着客戶端在頁面加載完成之前斷開連接(轉到另一頁/關閉瀏覽器)。如果客戶端正在下載文件,這個錯誤更可能是因爲他們有更多時間來決定退出/繼續。

該錯誤對用戶不可見* - 所以我剛剛將它從Elmah日誌中刪除。

*該網站只允許通過身份驗證的用戶。我能從Elmah看到誰經歷過錯誤和何時。我已經詢問了用戶,並且沒有一個人有曾報告報告在客戶端遇到此錯誤。

+0

嗨尼爾,所以沒有什麼可擔心的。我說得對嗎? – MoonLight

+0

是的。完全不用擔心。 –

+0

@NeilThompson,你能隱藏Elmah的這種錯誤嗎? – eduardobr

2

今天我遇到了這個問題,對我而言,這是因爲套接字超時等待遠程端發送。

在這個例子中,一個非常(或故意)慢的客戶端可能會導致異常。

我選擇通過增加套接字上的接收超時來解決它,因爲我想支持一些特定的較慢客戶端,這些客戶端因高SSL需求而被徵稅。

0

對這次派對遲了一點,但如果它幫助別人,Response.Close()在我的情況下導致異常。

我看到了由El描述的異常,由Elmah捕獲。

這是存在的由於閉合響應(I被支撐所述代碼被寫入到響應輸出流):

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

卸下Response.Close();停止被引發的異常。

2

我在用戶取消文件下載時遇到了該錯誤。在服務器端,它產生一個異常信息遠程主機關閉了連接。錯誤代碼是0x800703E3。但是,該異常沒有任何可以分開處理的不同類型。

在odrer處理它在ASP.NET MVC正確我添加了一個例外記錄:

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

而且WebExceptionLogger類實現:

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

我注意到,這specifict錯誤類型具有的HResult = -2147023901,所以這就是我要過濾的內容。

希望這會有所幫助。

相關問題