我们的控制台应用程序每分钟向 Facebook 发出数百个 Web 请求(使用多个应用程序和数百个访问令牌)。现在,他们开始失败,标题中出现异常消息(“请求已中止:请求已取消”)。我们在互联网上搜索了几个小时,并尝试了所有可能的解决方案,但没有任何帮助。
这些没有帮助:
webRequest.Timeout = 20000; //A request that didn't get respond within 20 seconds is unacceptable, and we would rather just retry.
webRequest.KeepAlive = false;
webRequest.ProtocolVersion = HttpVersion.Version10;
webRequest.ServicePoint.Expect100Continue = false;
有人还有其他想法吗?
edit:
异常的 ToString:System.Net.WebException:请求是
中止:请求被取消。 ---> System.Net.WebException:
请求被取消于
System.Net.ServicePointManager.FindServicePoint(Uri地址,IWebProxy
代理、ProxyChain& 链、HttpAbortDelegate& abortDelegate、Int32&
abortState) 在 System.Net.HttpWebRequest.FindServicePoint(Boolean
强制查找)在
System.Net.HttpWebRequest.DoSubmitRequestProcessing(异常&
异常)在 System.Net.HttpWebRequest.SetResponse(异常 E)---
内部异常堆栈跟踪结束 --- 位于
System.Net.HttpWebRequest.GetResponse() at WebException 消息:
请求被中止:请求被取消。
edit2:我们还没有达到极限。我们知道当这种情况发生时
问题并非如此。我们这样做已经两年了
而这样的事情在整个过程中只发生过两次。每
AccessToken 我们每分钟只执行 2-3 个请求,并且限制
Facebook 上的请求数/accesstoken/ip 为 600 个。
edit3:我想为有此问题或类似问题的人添加一个额外的提示:确保您处置您的 RequestStream、您的 Response 和您的 ResponseStream 对象。
http://www.dotnetframework.org/default.aspx/4@0/4@0/untmp/DEVDIV_TFS/Dev10/Releases/RTMRel/ndp/fx/src/Net/System/Net/ServicePointManager@cs/1305376/ ServicePointManager@cs http://www.dotnetframework.org/default.aspx/4@0/4@0/untmp/DEVDIV_TFS/Dev10/Releases/RTMRel/ndp/fx/src/Net/System/Net/ServicePointManager@cs/1305376/ServicePointManager@cs
我可以看到异常在哪里抛出。您是否尝试增加 HTTP 请求限制?默认值为每秒 2 个。
ServicePointManager.DefaultConnectionLimit = 1000;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)