为什么我在每次调用HttpWebResponse.GetResponse方法时都会超时?我调用它的频率并不重要。我试着每30秒拨打一次,2分钟 - 没有区别 - 第四次通话总是超时。
WebRequest request = WebRequest.Create(url);
request.Timeout = 15000;
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
using (WebResponse resp = e.Response)
{
Console.WriteLine(((HttpWebResponse)resp).StatusCode + ((HttpWebResponse)resp).StatusDescription);
}
}
}