There are multiple timeouts at play here.
If the connection has not yet been established and the host is not specified with an IP literal, then the first thing that happens is name resolution. If the DNS requests all time out (default should be after ~15 seconds on Windows), then the request will fail, regardless of what timeouts are configured on the HttpWebRequest
.
Then the transport level connection has to be established. In case of TCP, Windows' default timeout for that is 21 seconds. Same here: if this fails, the request fails, regardless of what's configured on the HttpWebRequest
.
Next comes the part where the HttpWebRequest
waits for the response headers. This is controlled by the Timeout
property, which defaults to 100 seconds.
And then comes reading the response data. According to the documentation, this is controlled by ReadWriteTimeout
, which defaults to 5 minutes. Note however that this is not the timeout for receiving all data. As long as some new data is being received with no "silent" phase of more than ReadWriteTimeout
, the request will not time out.
WebClient
/HttpWebRequest
timeouts are irrelevant. See my answer for some more details. – Linderman