473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Remote host closed the connection error - .Net 2

I have several web apps which download content to client (pdf, tif, etc) by
writing out content in an aspx page. I've recently upgraded these from 1.1
to 2.0....and they all seem to work fine except that every now and then the
apps raise the following error (our apps email us when an error occurs):
==================================
The remote host closed the connection. The error code is 0x80072746.
Stack
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.FlushCachedR esponse(Boolean
isFinal)
at System.Web.Hosting.ISAPIWorkerRequest.FlushRespons e(Boolean finalFlush)
at System.Web.HttpResponse.Flush(Boolean finalFlush)
at System.Web.HttpResponse.Flush()
==================================
Never had this message under 1.1 so my quesiton is: Is this a new type of
"error" under 2.0 that isn't really an error but just telling me the client
closed the browser before the content was sent.....or....is this an error I
need to be noting? If the later what is it telling me and how would I
address it?

Thanks

- Brad
May 2 '06 #1
7 5576
Hi Brad,

Thank you for posting.

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:

#httpRuntime Element (ASP.NET Settings Schema)
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.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 3 '06 #2
Steven - Thank you for the reply.
1. SSL is not an issue here, using staight http
2. No uploads always when writing a response to the client so request length
would not be an issue (but yes we have modified for some apps that require
it). I am writing out pdf and images, via aspx page, from sources not
direclty accessible by client. The majority are not large enough to to
result in a request timeout, but a few are and even in 1.1 I had changed the
time out, for example <httpRuntime executionTimeout="600" />. I am
capturing the errors in Application_Error, which is how I know about there
errors (our apps use a custom global class which emails full details of
errors, including page, full error and detials about client such as ip,
browser, etc). I know the exact pages where the error occurs but it is not
an error easily reproduced: considering these apps are accessed hundreds of
times a day the total number of errors amoung all of them is fifteen or less
a day.

Brad

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:7Q*************@TK2MSFTNGXA01.phx.gbl...
Hi Brad,

Thank you for posting.

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:

#httpRuntime Element (ASP.NET Settings Schema)
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.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


May 3 '06 #3
Hi Brad,

Thanks for your response.

So your ASP.NET 2.0 application's configuration has already adjusted the
exectionTimeout also, then that should not be the problem. BTW, is the
<compilation debug="..." /> attribute set to false in your application's
web.config, this is very important for release version application.

Also, I've performed some further check in our internal database and
haven't found any known issue of such behavior, so I think your application
is not suffering a common issue, still likely application or environement
specific. Yes, I agree with you that for such production environment it'll
be hard to create a simple reproduce, especially for this infrequently
occured problem.

So far what I can still get is checking the ASP.NET application's
restarting or the IIS worker process's recycling. It is possible that the
error is due to the worker process or application domain get restarted due
to some certain internal error(e.g high workload....). You can try writing
out some some trace entry in Application_End/Start event to see whether
those exception comes together with applicaiton restart. For IIS worker
process recycle, there should exists entry in system eventlog that we can
check.

Hope this also helps some.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
May 4 '06 #4
Hey Brad,

How are you doing on this issue? Have you got any further progress or does
my last reply also helps a little? If there is still anything we can do to
help you, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 8 '06 #5
Thanks for checking. No progress. No recycling or other errors in event
near time of this error. Below is an example of the code from one of the
applications which is getting the error. I still have not been able to
duplicate the error even using the same parameters that the cause the error
for the user. Other thoughts or suggestions are welcome.

Brad
====================
Note: code below is in an aspx devoted to presenting binary content (no
html content in page)
====================
With Current.Response
.ClearContent()
.ClearHeaders()

Select Case fi.Extension.ToLower
Case ".tif", ".tiff"
.ContentType = "image/tiff"
Case ".pdf"
.ContentType = "application/pdf"
End Select

'########################################
Dim fs As FileStream = New FileStream(imageFile, FileMode.Open,
FileAccess.Read)
Try
Dim FileLength As Integer = CType(fs.Length, Integer)
Dim buffer(FileLength) As Byte
fs.Read(buffer, 0, FileLength)
.BinaryWrite(buffer)

Catch ex As Exception
FileError()
Finally
fs.Close()
End Try
'########################################
.Flush()
.Close()
End With


"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:Wf**************@TK2MSFTNGXA01.phx.gbl...
Hey Brad,

How are you doing on this issue? Have you got any further progress or does
my last reply also helps a little? If there is still anything we can do to
help you, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
May 8 '06 #6
I found the problem and have been able to duplicate it successfully. Using
the code below, if page buffering is on (default) and the client browser
closes before the content is flushed the error consistently occurs. I was
able to duplicate this by running in debug, setting a breakpoint at the
flush and closing the browser before stepping through the flush.
Adding Buffer="false" to the Page declaration resolves the error.
With Current.Response
.ClearContent()
.ClearHeaders()

Select Case fi.Extension.ToLower
Case ".tif", ".tiff"
.ContentType = "image/tiff"
Case ".pdf"
.ContentType = "application/pdf"
End Select

'########################################
Dim fs As FileStream = New FileStream(imageFile, FileMode.Open,
FileAccess.Read)
Try
Dim FileLength As Integer = CType(fs.Length, Integer)
Dim buffer(FileLength) As Byte
fs.Read(buffer, 0, FileLength)
.BinaryWrite(buffer)

Catch ex As Exception
FileError()
Finally
fs.Close()
End Try
'########################################
.Flush()
.Close()
End With

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:Wf**************@TK2MSFTNGXA01.phx.gbl...
Hey Brad,

How are you doing on this issue? Have you got any further progress or does
my last reply also helps a little? If there is still anything we can do to
help you, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
May 8 '06 #7
Thanks for your followup Brad,

So from the further code you provided, the "connection be closed ..." error
is due to the client close the browser (or maybe client be disposed
expectedly), in such scenario, when the response is buffered, the binary
data is still not sucessfully transfer to client, then the error occurred.
Anyway, I think this is a reasonable behavior when the client stop the
connection expectedly. I used to be afraid that the connection is aborted
due to some server-side error such as application get restarted or process
crashed unexpectedly. That'll be very hard to troubleshoot.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 10 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff | last post by:
I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in the eNPTest02 directory of my localhost on my development machine. The database is on the web. ...
0
by: Mike | last post by:
VB .NET 2003, Pocket PC 2003, CF 1.0 SP 2 Only when I use a proxy server, I'm getting this error when attempting to write data to a Stream object from an HTTPWebRequest object....
1
by: balaya | last post by:
was an error downloading 'https://pushmxtest.equitynational.com/EquityNational/PushMXService.svc/secure'. The underlying connection was closed: An unexpected error occurred on a receive. Unable...
0
by: iKiLL | last post by:
Hi All Code Below for this problem ERROR: "An existing connection was forcibly closed by the remote host"
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.