The remote host closed the connection. The error code is 0x80072746.

Last post 01-26-2007 7:24 AM by kurtsune. 10 replies.

Sort Posts:

  • The remote host closed the connection. The error code is 0x80072746.

    11-15-2006, 7:14 AM
    • Member
      76 point Member
    • kurtsune
    • Member since 09-08-2006, 4:14 AM
    • Posts 30

    I have an asp 2.0 web.
    It very eagerly displays this error:
    (nothing shows up for the users)


    Message:

    The remote host closed the connection. The error code is 0x80072746.

    Stacktrace:

    at System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.FlushCore(Byte[]
    status, Byte[] header, Int32 keepConnected, Int32 totalBodySize, Int32
    numBodyFragments, IntPtr[] bodyFragments, Int32[] bodyFragmentLengths, Int32
    doneWithSession, Int32 finalStatus, Boolean& async)

    at System.Web.Hosting.ISAPIWorkerRequest.FlushCachedResponse(Boolean isFinal)

    at System.Web.Hosting.ISAPIWorkerRequest.FlushResponse(Boolean finalFlush)
    at System.Web.HttpResponse.Flush(Boolean finalFlush)

    at System.Web.HttpWriter.WriteFromStream(Byte[] data, Int32 offset, Int32 size)

    at System.Web.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)

    at Nymi.Logo.ProcessRequest(HttpContext context)

    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&completedSynchronously)



    I have googled and this error is not reffered to much.

    One solution is on every affected page set Page:Buffer="false"

    One other is in the .ashx set IsReusable = "false"


    Neither works for me.


    I do would appreciate further ideas.



    /k



  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-16-2006, 1:38 AM
    As for the "remote host closed connection exception...", it indicates the response of the ASP.NET worker thread has been closed due to some certain
    internal exception when flushing data out to the response stream. And from the internal diassemblied code, this error message is a general exception
    message and we can not get the detailed cause from it or the related exception handling code logic.

    Based on my experience, there is several possible things can cause the
    httprequest connection be closed unexpectedly.

    1. when establshing https/ssl connection
    2. when upload or flush out large data content cause the request timeout or exceed the max allowed request length.

    For your scenario, #1 is not likely the cause. I'm wondering how often does the error occur in your converted ASP.NET 2.0 applicaiton. Also, is
    the problem occuring when the page is flushing out large data content that is time consuming? For the ASP.NET request, there is max value setting for
    the request length and executiontime, I'm not sure whether your application or server has ever manualy modified that value in 1.X(in machine.config),
    and after converted to 2.0, the application will inherit 2.0's global configuration which hasn't changed the value accordingly? The
    executionTimeout and other httpRuntime related setting are in the following configuration element:
    http://msdn2.microsoft.com/en-us/lib...41(VS.80).aspx

    If you are using the Application_Error event to handle the unexpected exception, you can consider record the page that cause the problem. Thus,
    we can check whether the problem occurs on some page which has some common setting or code logic.

    Anyway, since this is a concrete project specific issue, it would be more helpful if we can generate a simplified page which can reproduce the
    behavior.
  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-16-2006, 3:30 AM
    • Member
      76 point Member
    • kurtsune
    • Member since 09-08-2006, 4:14 AM
    • Posts 30

    I trap the error in Application_Error. The error occurs in all pages in the web.

    The problem occurs in the production environment but not in the test environment.

    I have compared the machine.config and they are identical.

    All pages uses an .ashx to deliver a logo. 

    I will try to reproduce the error on a simplified page. 

    /k

     

  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-16-2006, 4:16 AM
    • Member
      76 point Member
    • kurtsune
    • Member since 09-08-2006, 4:14 AM
    • Posts 30

    I have reproduced the error with a simplified page.

    If I have my .ashx in the page the error occurs, otherwise not.

    The code in the .ashx below, can you spot my error?

     

    <%

    @ WebHandler Language="VB" Class="Apa.Logo" %>

    Option

    Strict On

    Option

    Explicit On

    Imports

    System

    Imports

    System.Web

    Imports

    System.Drawing

    Imports

    System.Drawing.Imaging

    Imports

    System.IO

    Imports

    System.Web.Caching

    Namespace

    Apa

     

    Public Class Logo : Implements IHttpHandler

    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    Dim imageID As String = context.Request.QueryString("Logo")

    Dim cacheKey As String = context.Request.CurrentExecutionFilePath & ":" & imageID

    Dim imageBytes As Byte()

    Dim cachedImageBytes As Object = context.Cache.Get(cacheKey)

    If Not cachedImageBytes Is Nothing Then

    imageBytes = CType(cachedImageBytes, Byte())

    Else

    Dim bm As Bitmap = DirectCast(System.Web.HttpContext.GetGlobalResourceObject("HeaderImageRes", "Logo.gif"), Bitmap)

    Dim stream As MemoryStream = New MemoryStream()

    bm.Save(stream, ImageFormat.Gif)

    stream.Close()

    bm.Dispose()

    imageBytes = stream.GetBuffer()

    context.Cache.Add(cacheKey, imageBytes, Nothing, DateTime.MaxValue, New TimeSpan(2, 0, 0), CacheItemPriority.Normal, Nothing)

    End If

    context.Response.ContentType = "image/gif"

    context.Response.Cache.SetCacheability(HttpCacheability.Public)

    context.Response.BufferOutput = False

    context.Response.OutputStream.Write(imageBytes, 0, imageBytes.Length)

    End Sub

    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    End

    Namespace
  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-16-2006, 4:16 AM
    • Member
      76 point Member
    • kurtsune
    • Member since 09-08-2006, 4:14 AM
    • Posts 30

    I have reproduced the error with a simplified page.

    If I have my .ashx in the page the error occurs, otherwise not.

    The code in the .ashx below, can you spot my error?

     

    <%

    @ WebHandler Language="VB" Class="Apa.Logo" %>

    Option

    Strict On

    Option

    Explicit On

    Imports

    System

    Imports

    System.Web

    Imports

    System.Drawing

    Imports

    System.Drawing.Imaging

    Imports

    System.IO

    Imports

    System.Web.Caching

    Namespace

    Apa

     

    Public Class Logo : Implements IHttpHandler

    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    Dim imageID As String = context.Request.QueryString("Logo")

    Dim cacheKey As String = context.Request.CurrentExecutionFilePath & ":" & imageID

    Dim imageBytes As Byte()

    Dim cachedImageBytes As Object = context.Cache.Get(cacheKey)

    If Not cachedImageBytes Is Nothing Then

    imageBytes = CType(cachedImageBytes, Byte())

    Else

    Dim bm As Bitmap = DirectCast(System.Web.HttpContext.GetGlobalResourceObject("HeaderImageRes", "Logo.gif"), Bitmap)

    Dim stream As MemoryStream = New MemoryStream()

    bm.Save(stream, ImageFormat.Gif)

    stream.Close()

    bm.Dispose()

    imageBytes = stream.GetBuffer()

    context.Cache.Add(cacheKey, imageBytes, Nothing, DateTime.MaxValue, New TimeSpan(2, 0, 0), CacheItemPriority.Normal, Nothing)

    End If

    context.Response.ContentType = "image/gif"

    context.Response.Cache.SetCacheability(HttpCacheability.Public)

    context.Response.BufferOutput = False

    context.Response.OutputStream.Write(imageBytes, 0, imageBytes.Length)

    End Sub

    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    End

    Namespace
  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-27-2006, 5:05 AM
    Yes,I can repro the error message saying that the remote host closed the connection.Here are some readings about IHttpHandler for your reference.
    http://discuss.joelonsoftware.com/default.asp?dotnet.12.323321.5
    http://blogs.msdn.com/smourier/archive/2003/05/16/7125.aspx
    http://www.vbinfozine.com/c/13_Download.vb.shtml
    Wish the above can give you some helps.
  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-27-2006, 5:33 AM
    • Member
      76 point Member
    • kurtsune
    • Member since 09-08-2006, 4:14 AM
    • Posts 30

    Thanks for your answer.

    My problem is that the handler works on four servers but not on the fifth, which unfortunately is the production box.

    I have a case with MS on this matter. The question is "How to troubleshoot this?"

    I'll post a solution when I've got one.

     

    k

  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-27-2006, 9:24 PM
    Try to take a look at this KB from Microsoft - http://support.microsoft.com/kb/307997/EN-US/
    Wish it can give you some helps.
  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-27-2006, 9:29 PM
    You can also debug an HTTP Handler (*.ashx) in ASP.NET 2.0 and try to solve the problem as the following link.
    http://www.15seconds.com/Issue/060406.htm
    Wish this can give you some helps.
  • Re: The remote host closed the connection. The error code is 0x80072746.

    11-28-2006, 4:09 AM
    • Member
      76 point Member
    • kurtsune
    • Member since 09-08-2006, 4:14 AM
    • Posts 30

    Thanks for the tip.

     I read the 15seconds-article. I accessed the .ashx directly in the browser.

    On the production machine the error occurs. On the test server it did not.

    Sadly I have no opportunity debugging in production, and the error doesn't occur in any test environment. :-(

    I also checked the app configuration which are identical on both servers.

    /k

     

  • Re: The remote host closed the connection. The error code is 0x80072746.

    01-26-2007, 7:24 AM
    • Member
      76 point Member
    • kurtsune
    • Member since 09-08-2006, 4:14 AM
    • Posts 30

    Solution found.

    Contrary to http://weblogs.asp.net/shankun/archive/2004/08/16/215487.aspx

    this must be set to true:  HttpContext.Response.BufferOutput = True

    , otherwise chunking might occur and then the error .

     

    /k

Page 1 of 1 (11 items)