2011-06-21 131 views
1

使用在Azure上作为计划任务运行的控制台应用程序在Azure上运行的所有长(ish)网页。几分钟后底层连接已关闭:接收时发生意外错误

问题:基础连接已关闭:意外出错一个接收

//// used as WebClient doesn't support timeout 
public class ExtendedWebClient : WebClient 
{ 
    public int Timeout { get; set; } 

    protected override WebRequest GetWebRequest(Uri address) 
    { 
     HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address); 
     if (request != null) 
      request.Timeout = Timeout; 
     request.KeepAlive = false; 
     request.ProtocolVersion = HttpVersion.Version10; 
     return request; 
    } 

    public ExtendedWebClient() 
    { 
     Timeout = 1000000; // in ms.. the standard is 100,000 
    } 
} 

class Program 
{ 
    static void Main(string[] args) 
    { 
     var taskUrl = "http://www.secret.com/secret.aspx"; 
     // create a webclient and issue an HTTP get to our url 
     using (ExtendedWebClient httpRequest = new ExtendedWebClient()) 
     { 
      var output = httpRequest.DownloadString(taskUrl); 
     } 
    } 
} 

回答

2

请注意,Windows Azure负载平衡器在60秒后终止空闲TCP连接。它看起来像是通过负载平衡器调用的...有没有可能在60秒内没有发送任何东西?

+0

没有完全解决..但要去一个控制台应用程序。 –

0

运行像Wireshark的观看连接,并找出哪些端关闭它。这种奇怪可能是由于你和你的服务器之间的路由器MTU低于你的。我想你可以在WCF配置中设置MTU,不知道Azure。

+0

喜彼得 - Chrome上运行时,它后45secs ...不知道这是否是显著某种存活的。用Wireshark得到了这个..干杯。开始努力......考虑重新设计! TCP [TCP Keep-Alive] 61687> http [ACK] Seq = 0 Ack = 1 Win = 65700 Len = 1 –

相关问题