Hi
I am using the httpwebrequest object in C# (.NET FW 3.5SP1) to get the data from a webserver. When the webser is not alive, the httpWebResponse .GetResponse throws the time out exception at around 20 secs, even if I am setting my time out to 30 secs. Even if I don't set any time out, it returns back in 20 secs. Whats the deal with 20 secs and how can I change it? I have gone thru a lot of posts in forums, no breakthru yet. Please help.
Here is my test code.
I am using the httpwebrequest object in C# (.NET FW 3.5SP1) to get the data from a webserver. When the webser is not alive, the httpWebResponse .GetResponse throws the time out exception at around 20 secs, even if I am setting my time out to 30 secs. Even if I don't set any time out, it returns back in 20 secs. Whats the deal with 20 secs and how can I change it? I have gone thru a lot of posts in forums, no breakthru yet. Please help.
Here is my test code.
Code:
try
{
WebRequest wrq = WebRequest.Create( "www.nonexistentwebsite.com" );
HttpWebRequest hwrq = ( HttpWebRequest ) wrq;
hwrq.Timeout = 30000;
hwrq.ReadWriteTimeout = 50000;
WebResponse wrs = wrq.GetResponse();
stream = wrs.GetResponseStream();
if( stream != null )
{
//analyze data
stream.Close();
}
}
catch( Exception ex )
{
ex.ToString();
//No matter what time out is set, this exception is reached in exactly 20 or 21 secs.
}
Comment