2013-06-18 165 views
1

我正在使用服務以XML文檔的形式提取酒店列表。所有這一切都在部署使用這種被打破過的所有網頁後進行測試時它,但是矮子並顯示該錯誤的原理我們的開發服務器上的罰款:HttpWebRequest問題:系統缺少足夠的緩衝區空間或隊列已滿

An operation on a socket could not be performed because the system lacked 
sufficient buffer space or because a queue was full 91.103.175.187:80 

Description: An unhandled exception occurred during the execution of the current 
web request. Please review the stack trace for more information about the error 
and where it originated in the code. 

Exception Details: System.Net.Sockets.SocketException: An operation on a socket 
could not be performed because the system lacked sufficient buffer space or 
because a queue was full 91.103.175.187:80 

Stack Trace: 

[SocketException (0x2747): An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full 91.103.175.187:80] 
    System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +305 
    System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +699 

[WebException: Unable to connect to the remote server] 
System.Net.HttpWebRequest.GetResponse() +7859156 
Laterooms.Gateway.LateroomsGateway.GetHotelsWithurl(String url) 
Laterooms.Gateway.LateroomsGateway.GetHotelsByKeyword(String keyword, String orderBy) 
Laterooms.LateroomsManager.GetHotelsByKeyword(String keyword, String orderBy, String lang) 

看到這個之後,我認爲這可能是由於到所要求的數量,所以我實現了緩存但仍然發生相同的問題。這裏是我用來拉入數據的代碼:

HttpWebRequest request = null; 

    Uri uri = new Uri(url); 
    request = (HttpWebRequest)WebRequest.Create(uri); 
    request.Method = "POST"; 
    request.AllowWriteStreamBuffering = false; 
    request.ContentLength = 0; 
    request.KeepAlive = false; 

    using (WebResponse response = request.GetResponse()) 
    { 
     using (Stream dataStream = response.GetResponseStream()) 
     { 
      _LateroomsXml.Load(dataStream); 
     } 
    } 

此問題只發生在我們的在線服務器上。經過幾個小時的調試和谷歌搜尋,我還沒有接近解決這個問題。

任何幫助,將不勝感激!

+1

什麼虛擬內存分配給活箱 - 我曾經有一個非常類似的問題,一旦虛擬內存不足造成的,即使服務器本身有足夠的標準內存 – Johnv2020

+0

它有4GB分配給它,現在它只運行在2GB 。我認爲這可能也是問題,但似乎並非如此。 – shoughton123

+0

[「無法執行套接字上的操作,因爲系統缺少足夠的緩衝區空間或者因爲隊列已滿」](http://stackoverflow.com/questions/4415175/an-operation-on-a -socket-could-be-performing-because-the-system-lacked-suffi) – Ash

回答

2

我在最後發現了這個問題的解決方案,以防其他人卡住!

here

https://support.microsoft.com/en-us/kb/196271

  1. 啓動註冊表編輯器。

  2. 在註冊表中找到下面的子項,然後單擊參數: HKEY_LOCAL_MACHINE \系統\ CurrentControlSet \服務\ TCPIP \參數

  3. 在編輯菜單上,單擊新建,然後添加以下注冊表項:

    值名稱:MaxUserPort的

    值類型:DWORD

    值數據:65534

    有效範圍:5000-65534(十進制)

    默認值:0x1388(5000十進制)

  4. 退出註冊表編輯器,然後重新啓動計算機。

這與一些更好的緩存,因此數據不被拉到每一個用戶加載頁面將防止這種情況再次發生的時間相結合。

+0

你能解釋一下這到底是怎麼回事? – JohnTube

+0

您可以在[鏈接]中找到完整的答案(http://www.outsystems.com/forums/discussion/6956/how-to-tune-the-tcp-ip-stack-for-high-volume-of -web-請求/)。 – Flayn

+0

這不是一個解決方案,它是一個黑客,它只會推遲問題,直到你面對更高的負載 – mfarouk

8

請不要使用該修復程序。你的問題是你禁用了Alive,所以它對每個請求都使用不同的連接,並且一個端口在幾分鐘內無法再使用。它正在做它應該做的事情。

啓用保持活動並且您的問題將消失。

相關問題