AS 4.x bug: 15-second timeout in HTTP connections.
- From: "ajdavis" <jdavis@xxxxxxxx>
- Date: 21 Nov 2005 10:27:17 -0800
There's a bug in AS 4.0 and 4.1 during HTTP downloads over USB with
KeepAlive set to false. I posted about this when 4.0 came out, but now
that I've determined it's still in 4.1, my wrath grows, and I want
everyone to know about the bug. Maybe if I shout loud enough MS will
listen.
I'm using Compact Framework 2.0 (the behavior is also in 1.0), a Pocket
PC 2003 (haven't had a chance to test WM 5.0 yet), Windows XP SP2.
In a C# test app I wrote, I download a 54 k web page, in 2 k blocks,
pausing 1 second between each block. So the download should take a
little over 27 sec. However, after 15 sec I get
"System.Net.Sockets.SocketException: An existing connection was
forcibly closed by the remote host". I can adjust the block size,
total size, and the length of the pause -- the invariant is, I always
get a SocketException after 15 sec.
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(downloadUrl);
request.Method = "GET";
request.ProtocolVersion = HttpVersion.Version11;
request.KeepAlive = false;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
int nread = -1;
while (nread != 0)
{
nread = responseStream.Read(buffer, 0, bufSz);
Thread.Sleep(1000);
}
Watching in Ethereal, I see that the desktop downloads all 54 k in a
few millisec, and buffers it. My app slowly reads from that buffer.
(I.e., there's a virtual connection over USB that emulates a direct
connection between the Pocket PC and the server.) After 15 sec of
inactivity in the connection between the desktop and the server, the
desktop closes the connection.
Expected: my app can continue to read from the buffered 54 k until
it's read it all. The virtual connection (USB) is unaffected when the
real connection is closed.
Actual: Once the real connection is closed, the next time my app tries
to read from the stream, it gets a SocketException.
Workaround: Setting KeepAlive true seems to work in both AS 4.0 and
4.1. Just remember that KeepAlive isn't supported in HTTP 1.0.
request.ProtocolVersion = HttpVersion.Version11;
request.KeepAlive = true;
Anyone who wants my test app, just email me.
Jesse.
.
- Prev by Date: Re: Error Bluetooth
- Next by Date: My Active Sync has Alzheimers
- Previous by thread: Re: Error Bluetooth
- Next by thread: My Active Sync has Alzheimers
- Index(es):
Relevant Pages
|