monkey_boys
monkey_boys

Reputation: 7348

Setting the timeout when trying to connect to a remote server using HttpWebRequest?

How to increase the timeout when connecting to a remote server uwing HttpWebRequest?

Upvotes: 0

Views: 890

Answers (2)

David Perlman
David Perlman

Reputation: 1470

First off there is HttpWebRequest.Timeout. Details Here (and in the answer that was posted while I was typing).. Second I would suggest using System.Net.WebClient which has a very simple to use interface. Setting a timeout on a WebClient is explained here.

Upvotes: 0

dpurrington
dpurrington

Reputation: 1533

If you're using HttpWebRequest, you should set Timeout to the desired value:

HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
request.Timeout = 5000 // in ms, the default is 100,000
request.GetResponse();

Upvotes: 1

Related Questions