gpt4 book ai didi

c# - HttpWebRequest 问题 : System lacked sufficient buffer space or because a queue was full

转载 作者:行者123 更新时间:2023-11-30 13:22:54 25 4
gpt4 key购买 nike

我正在使用一项服务以 XML 文档的形式提取酒店列表。所有这些在我们的开发服务器上测试时都运行良好,但是在部署它后不久,所有使用它的页面都被破坏并显示此错误:

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);
}
}

同样,此问题仅发生在我们的实时服务器上。经过几个小时的调试和谷歌搜索,我还没有更接近于解决这个问题。

如有任何帮助,我们将不胜感激!

最佳答案

请不要使用该修复程序。您的问题是您禁用了 keep alives,因此它为每个请求使用不同的连接,并且一个端口在几分钟内无法再次使用。它正在做它应该做的事情。

启用 keep-alive,您的问题就会消失。

关于c# - HttpWebRequest 问题 : System lacked sufficient buffer space or because a queue was full,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17167977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com