gpt4 book ai didi

c# - 请求被中止 : The request was canceled. 没有解决方案

转载 作者:太空狗 更新时间:2023-10-29 18:31:44 24 4
gpt4 key购买 nike

我们的控制台应用程序每分钟向 Facebook 发出数百个 WebRequests(使用多个应用程序和数百个访问 token )。现在,他们开始失败,标题中出现异常消息(“请求被中止:请求被取消”)。我们在互联网上搜索了几个小时,并尝试了所有可能的解决方案,但没有任何帮助。

这些没有帮助:

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;

还有人有其他想法吗?

编辑:

ToString of the Exception: System.Net.WebException: The request was aborted: The request was canceled. ---> System.Net.WebException: The request was canceled at System.Net.ServicePointManager.FindServicePoint(Uri address, IWebProxy proxy, ProxyChain& chain, HttpAbortDelegate& abortDelegate, Int32& abortState) at System.Net.HttpWebRequest.FindServicePoint(Boolean forceFind) at System.Net.HttpWebRequest.DoSubmitRequestProcessing(Exception& exception) at System.Net.HttpWebRequest.SetResponse(Exception E) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at WebException message: The request was aborted: The request was canceled.

edit2:我们还没有达到极限。我们知道什么时候发生,问题不在于此。我们已经这样做了两年,而这件事在整个过程中只发生过两次。每AccessToken 我们每分钟只做 2-3 个请求,并且限制在 Facebook 上是 600 个请求/accesstoken/ip。

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 请求限制?默认值为每秒 2 次。

ServicePointManager.DefaultConnectionLimit = 1000;

关于c# - 请求被中止 : The request was canceled. 没有解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21548604/

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