5

my Code:

System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://192.168.2.2/web/movielist");
req.Timeout = 2000;
System.Net.WebResponse res = req.GetResponse();
System.IO.Stream responseStream = res.GetResponseStream();

The requested document (movielist) is a very big document and it requires more than 10 seconds to retrieve it complete.

I want to only set a timeout for establishing the connection itself. As far as i can see req.Timeout is a timeout for the whole request not only establishing the connection. There should be no timeout for retrieving the document.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Hans99
  • 51
  • 1
  • 1
  • 2

1 Answers1

1

That timeout is in milliseconds - so 2000ms = only 2 seconds. You can't specify a connection establish timeout - the timeout is for the whole request. Try changing 2000 to 20000 (20 seconds) or higher to avoid timeouts.

Matt Chepeleff
  • 419
  • 2
  • 7