1
我有一个非常简单的HTTP得到应用,这里是它为什么WebRequest只能工作两次?
using System;
using System.Net;
using System.Threading;
namespace UploadRichardsStatusConsoleApplication
{
class Program
{
static void Main()
{
const string requestString = "http://www.google.com/";
while (true)
{
var request = WebRequest.Create(requestString);
Console.WriteLine("request sent = " + requestString);
try
{
var response = request.GetResponse();
Console.WriteLine("response.ContentLength = " + response.ContentLength);
}
catch (WebException)
{
Console.WriteLine("Request timed out");
}
Thread.Sleep(5000);
}
}
}
}
一个更简单的删节版真正的控制台应用程序,有我自己的Azure的URL,但问题表现任何请求字符串,即使谷歌,所以我不认为这是一个服务器端问题。当我运行代码时,前两个循环成功,即报告了response.ContentLength
。此后,他们超时。为什么我只接到两个电话?我工作的实际应用使用了HTTP GET定期报告状态,所以我必须这样做反复
我要指出,我已经试过(两倍以上!):
- 添加未使用的查询属性到URL这些工作,使每个URL是 不同
- 设置超时巨大价值
- 绕过高速缓存
但没有编辑。
这一工程 - 感谢乔恩(我时,我可以接受在几分钟的答案)。 – dumbledad 2013-05-01 14:50:58