J
jehugaleahsa
Here is a post from ages ago that never got replied to. However, I
have experienced similar issues with WebRequest. It is as though the
class will wait until the timeout is over..
I recently removed a WebRequest that attempted to retrieve content-
length because the code hung at that line. And I, too, have witnessed
the data being transferred. It seems to me like a bug.
Here is an even more simple example:
WebRequest request = HttpWebRequest.CreateDefault(new
Uri("http://www.google.com"));
request.Method = "HEAD";
request.Timeout = 10000;
WebResponse response = request.GetResponse();
string length = response.Headers["Content-Length"];
Is this a bug or an developer-education problem?
Thanks,
Travis
Kenneth Brady
Newsgroups: microsoft.public.dotnet.languages.csharp
From: ken.brady@<nospan>verizon.net (Kenneth Brady)
Date: Fri, 25 Jul 2003 02:58:02 GMT
Local: Thurs, Jul 24 2003 7:58 pm
Subject: WebRequest.GetResponse times out even though the data has
arrived
I have a class which accesses a cgi server. I've tested the
operation
of this class in a simple console app, and it works fine. Using the
class in its intended environment, a Forms app in which the network
access is done on a worker thread, the GetResponse() method of my
WebRequest instance hangs (until it times out), even though I can see
the data come in on my network monitor.
I also have a method on my class which uses the asynchronous methods
of the WebRequest. As above, it works fine in a simple console
client, but in my production context, the callback passed to
BeginGetResponse() is never invoked.
Here is the synchronous code:
public void fetch()
{ beginUse();
DateTime start = DateTime.Now;
// url is a private property returning the
// cgi request string.
WebRequest req = WebRequest.Create(url);
req.Timeout = 120000; // 2 min
// This line hangs in my multithreaded application,
// even though I can see the data come back
// over the network.
WebResponse resp = req.GetResponse();
StreamReader rdr = new
StreamReader(resp.GetResponseStream());
Stats.add(DateTime.Now-start); // monitor
try { parse(rdr.ReadToEnd());}
finally
{ rdr.Close();
endUse();
}
}
Thanks in advance!
have experienced similar issues with WebRequest. It is as though the
class will wait until the timeout is over..
I recently removed a WebRequest that attempted to retrieve content-
length because the code hung at that line. And I, too, have witnessed
the data being transferred. It seems to me like a bug.
Here is an even more simple example:
WebRequest request = HttpWebRequest.CreateDefault(new
Uri("http://www.google.com"));
request.Method = "HEAD";
request.Timeout = 10000;
WebResponse response = request.GetResponse();
string length = response.Headers["Content-Length"];
Is this a bug or an developer-education problem?
Thanks,
Travis
Kenneth Brady
Newsgroups: microsoft.public.dotnet.languages.csharp
From: ken.brady@<nospan>verizon.net (Kenneth Brady)
Date: Fri, 25 Jul 2003 02:58:02 GMT
Local: Thurs, Jul 24 2003 7:58 pm
Subject: WebRequest.GetResponse times out even though the data has
arrived
I have a class which accesses a cgi server. I've tested the
operation
of this class in a simple console app, and it works fine. Using the
class in its intended environment, a Forms app in which the network
access is done on a worker thread, the GetResponse() method of my
WebRequest instance hangs (until it times out), even though I can see
the data come in on my network monitor.
I also have a method on my class which uses the asynchronous methods
of the WebRequest. As above, it works fine in a simple console
client, but in my production context, the callback passed to
BeginGetResponse() is never invoked.
Here is the synchronous code:
public void fetch()
{ beginUse();
DateTime start = DateTime.Now;
// url is a private property returning the
// cgi request string.
WebRequest req = WebRequest.Create(url);
req.Timeout = 120000; // 2 min
// This line hangs in my multithreaded application,
// even though I can see the data come back
// over the network.
WebResponse resp = req.GetResponse();
StreamReader rdr = new
StreamReader(resp.GetResponseStream());
Stats.add(DateTime.Now-start); // monitor
try { parse(rdr.ReadToEnd());}
finally
{ rdr.Close();
endUse();
}
}
Thanks in advance!