HttpWebRequest Timeout
14,678
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.
Author by
Admin
Updated on June 15, 2022Comments
-
Admin almost 2 years
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.