Our console applications are making hundreds of WebRequests to Facebook every minute (with using multiple apps and hundreds of access tokens). Now, they started to fail with the exception message in the title ("The request was aborted: The request was canceled"). We searched for hours on the internet, and tried out every possible solution, but nothing helped.
These didn't help:
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;
Anyone has any other idea?
edit:
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: And we are NOT reaching the limit. We know when that happens, and the problem is NOT that. We have been doing this for two years, and this thing only happened twice during the whole time. Per AccessToken we are only doing 2-3 requests/minute, and the throttling on Facebook is 600 requests/accesstoken/ip.
edit3: I would like to add an extra tip for people who have this or similar problem: Make sure that you dispose your RequestStream, your Response and your ResponseStream object.
I can see where the exception is thrown. Did you try increasing the HTTP request limit? The default is 2 per seconds.
ServicePointManager.DefaultConnectionLimit = 1000;