The remote host closed the connection

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for .NET (v4)  /  Re: The remote host closed the connection

DynamicPDF Generator for .NET (v4) Forum

Hi

I am using DynamicPDF for web application. Before making call to DynamicPDF.Document.DrawToWeb method code check that client is connected or not with Response.IsClientConnected property. If client is connected then only call is made to DynamicPDF.Document.DrawToWeb method.

From stack trace below I found that DynamicPDF.Document.DrawToWeb call HttpResponse.Flush. Below is stack trace

System.Web.HttpException
:
The remote host closed the connection. The error code is 0x800703E3.


Business Context
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 ceTe.DynamicPDF.Document.a(HttpRequest A_0, HttpResponse A_1, Boolean A_2, String A_3, Boolean A_4)
   at ceTe.DynamicPDF.Document.DrawToWeb(Boolean allowBrowserCaching, String downloadAsFileName, Boolean forceDownload)

From asp.net forums I came to know that before calling System.Web.HttpResponse.Flush we need to check
Response.IsClientConnected. My question is does DynamicPDF.Document do this check before calling Response flush ?

Please suggest any other workaround if you have for this problem?

Thanks
Satish
Posted by a ceTe Software moderator
Hello Satish,

Can you please send over the exact version and the build number of the DynamicPDF dll file and the sample code using which we can recreate the error? Also send over the exact version and name of the operating system you are using to our support team at: support@cete.com so that they can look into it further.

Thanks,
ceTe Software Support Team.
I have the same issue.  When a user closes their browser window before the PDF has been rendered I receive an error with the stack trace below.  I attempted to use the following code to fix the issue:

// Only draw the PDF if the client is connected.  Used to fix the following error: The remote host closed the connection. The error code is 0x80072746.
                        if (Response.IsClientConnected)
                        {
                                // Draw PDF
                                PDF.DrawToWeb();
                        }

The stack trace is:

Exception Detail: System.Web.HttpException: The remote host closed the connection. The error code is 0x80072746. 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.HttpResponse.Flush() at ceTe.DynamicPDF.Document.a(HttpRequest A_0, HttpResponse A_1, Boolean A_2, String A_3, Boolean A_4) at ceTe.DynamicPDF.Document.DrawToWeb(Boolean allowBrowserCaching, String downloadAsFileName, Boolean forceDownload) at ceTe.DynamicPDF.Document.DrawToWeb() at PS.PDF.Base.BasePDFGeneratorPage.Draw() in c:\Inetpub\wwwroot\Medicare\App_Code\PDF\Base\BasePDFGeneratorPage.cs:line 58 at PS.PDF.Base.BasePDFGeneratorPage.Generate() in c:\Inetpub\wwwroot\Medicare\App_Code\PDF\Base\BasePDFGeneratorPage.cs:line 41 at Medicare.DocumentGenerators.FormularyGeneratorPage.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Medicare\DocumentGenerators\FormularyGeneratorPage.aspx.cs:line 52

Any help is appreciated.

Thanks!
Matt L.
My apologies for posting this in the wrong forum.  I am on V6.0.2 Build 19068.  I didn't realize this thread was in the v4.x forum.  Issue still applies though.  Let me know if you want me to open up a new thread in the appropriate forum.

Thanks!
Matt L.
Posted by a ceTe Software moderator
Hello Matt,
 
No problem, we can address this issue in this forum since it’s the same product. These errors are thrown by the ASP.NET when calling the Response.Flush() method if the user cancels the request while the file is being streamed to the client browser. Check out this link for more details. These errors can be caused if you stream any file in the server side code.

The DrawToWeb of our API streams the PDF file to the browser as explained in the above link, and it does check for Response.IsClientConnected before the Flush method is called. You could try the solution suggested in this link or you can use the file streaming code show in the below sample as a workaround instead of using the DrawToWeb method.

        Document document = new Document();
        Page page = new Page();
        document.Pages.Add(page);
        TextArea textArea = new TextArea("This is the underlined " + "text of a TextArea", 100, 100, 400, 30,ceTe.DynamicPDF.Font.HelveticaBoldOblique, 18);
        textArea.Underline = true;
        page.Elements.Add(textArea);
        byte[] byteData=  document.Draw();
        this.Response.ClearHeaders();
        this.Response.ClearContent();
        this.Response.ContentType = "application/pdf";
        this.Response.Charset = string.Empty;
        this.Response.AddHeader("Content-Disposition", "inline; filename=" + "HelloWorld.pdf ");
        this.Response.BinaryWrite(byteData);

Thanks,
ceTe Software Support Team.
Instead of DrawToWeb method try with below code. inside your if statment.

        Document document = new Document();
        Page page = new Page();
        document.Pages.Add(page);
        TextArea textArea = new TextArea("This is the underlined " + "text of a TextArea", 100, 100, 400, 30,ceTe.DynamicPDF.Font.HelveticaBoldOblique, 18);
        textArea.Underline = true;
        page.Elements.Add(textArea);
        byte[] byteData=  document.Draw();

        //Rendering the generated PDF document in the browser using BinaryWriter method instead of using DrawToWeb method.
        this.Response.ClearHeaders();
        this.Response.ClearContent();
        this.Response.ContentType = "application/pdf";
        this.Response.Charset = string.Empty;
        this.Response.AddHeader("Content-Disposition", "inline; filename=" + "HelloWorld.pdf ");
        this.Response.BinaryWrite(byteData);

We are having the same problem after migration:
It was working fine on the OS Windows 2003 R2 with DynamicPDF v6.
We migrated the production to the OS Windows 2008 R2 with DynamicPDF v6. After this we are getting the error:

MESSAGE: The remote host closed the connection. The error code is 0x800703E3.
SOURCE: System.Web
STACK TRACE:
[System.Web.HttpUnhandledException:Boolean HandleError(System.Exception)]
   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.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.secure_offerletter_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

[System.Web.HttpException:Void RaiseCommunicationError(Int32, Boolean)]
   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.HttpResponse.Flush()
   at ceTe.DynamicPDF.Document.a(HttpRequest A_0, HttpResponse A_1, Boolean A_2, String A_3, Boolean A_4)
   at ceTe.DynamicPDF.Document.DrawToWeb(Boolean allowBrowserCaching, String downloadAsFileName, Boolean forceDownload)
   at ceTe.DynamicPDF.Document.DrawToWeb(String downloadAsFileName, Boolean forceDownload)

Please guide us.
Posted by a ceTe Software moderator
Hello,

Can you please try using the latest version 6 DynamicPDF dll file in your application and see if it works for you? You can download the latest version 6 DynamicPDF dll files by logging into our CustomerArea: CustomerArea using your version 6 product serial number. Remove reference for the old dll file and reference the latest dll file in your application.

If you continue getting the error even after using the latest DynamicPDF dll file then please send over the following details to our support team so that they can look into it further.

1.Sample project using which our support team can recreate the error.
2.Steps to recreate the error.
3.Full error message along with the stack trace.
4.Exact version and build number of the DynamicPDF dll file.
5.Input files(if you are using any for merging).

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 1:02 AM.