2012-09-11 44 views
-1

我在Quartz.Net框架中使用它。每一個工作(線程)只有一個web請求爲什麼我無法在HttpWebRequest上獲取超時? (HttpWebRequest超時噩夢)

下面是檢查表:

  • 所有一次性物品使用塊使用!

    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) 
         using (Stream stream = response.GetResponseStream()) 
         using (StreamReader reader = new StreamReader(stream)) 
          str = reader.ReadToEnd(); 
    
  • ServicePointManager.Expect100Continue = false;
  • ServicePointManager.DefaultConnectionLimit = 1000;
  • ServicePointManager.MaxServicePoints = 1000;
  • request.KeepAlive = false
  • request.Timeout = 5000;
  • request.ReadWriteTimeout = 5000;
  • request.ServicePoint.ConnectionLeaseTimeout = 5000;
  • request.ServicePoint.MaxIdleTime = 5000;

我使用秒錶來衡量Web請求時間。這些都是日誌:

異常的Web請求時:16333毫秒

異常的Web請求時間:8350毫秒

異常的Web請求時間:9846毫秒

異常的Web請求時間:7545毫秒

異常的Web請求時間:6662毫秒

異常的Web請求時:18332毫秒

任何想法?

PS:這個問題進行了總結版Timeout supported Multithreaded Web Request

回答

0

只有我從這個問題學到的教訓:如果您在多個線程使用的HttpWebRequest不使用它同步!

相關問題