Re: Why Would ResponseStream().Read return zero bytes when not at end of file?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Fri, 11 Jan 2008 13:06:26 -0800, Rymfax <cwalker@xxxxxxxxxxxxxx> wrote:

[...]
It is possible that it is reading zero bytes because the connection is
closing prematurely, but this is suppose to generate an exception

That's not true. You'll get an exception if the connection is _reset_, but if it's simply closed then you get a 0 byte receive.

which I check for (I actually check for any exception).
So I don't
know what could be causing the ResponseStream to return zero bytes if
it hasn't reached the end of the content (according to the
ContentLength anyway).

As I said, there is no network requirement that the number of bytes delivered by the server before closing the connection is identical to the number of bytes the server advertised in the HTTP response. The advertised length is just that: an advertisement. The network side of things doesn't enforce it.

One would expect a correctly-behaving HTTP server to provide the bytes as advertised, but servers don't always behave, and on top of that some ISPs are known to mess with TCP connections, including doing something like closing it for no good reason.

I've already coded in a re-check for when this
happens, but I was hoping to figure out WHY it is happening.

That's an admirably goal. But the only way you can do that is by doing some debugging. You need to monitor the network traffic at both ends and figure out who is closing the connection. Once you've identified that, then you can look at why. Unfortunately, a vague problem description is not enough information for anyone else in this newsgroup to answer the question. Only first-hand knowledge will do.

Pete
.



Relevant Pages

  • Re: Implications of not closing db connection?
    ... "vivienne wykes" wrote in message ... > an issue for other server users by not closing the db connection. ...
    (comp.lang.java.programmer)
  • Re: How to "kill" a tcp port...
    ... Are you saying there is no way of closing the ... keeps the connection open because the client-side was still ... > 2.TCP itself should give the client an error if the server dies without ... The server process did die (can't see it in Task Manager for any user). ...
    (microsoft.public.dotnet.framework)
  • Re: How to "kill" a tcp port...
    ... Are you saying there is no way of closing the ... keeps the connection open because the client-side was still ... > 2.TCP itself should give the client an error if the server dies without ... The server process did die (can't see it in Task Manager for any user). ...
    (microsoft.public.dotnet.general)
  • Re: How to "kill" a tcp port...
    ... Are you saying there is no way of closing the ... keeps the connection open because the client-side was still ... > 2.TCP itself should give the client an error if the server dies without ... The server process did die (can't see it in Task Manager for any user). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Outgoing POP3 email missing/lost/not received
    ... Funny thing is that I have had this ISP for 8 years and it has always been ... It looks like when you last ran CEICW, you set the ISP's mail server to: ... Internet Connection Wizard. ... After the wizard completes, the following network connection ...
    (microsoft.public.windows.server.sbs)