System.Net.HttpWebRequest.GetRequestStream Timeout problem

Source: Internet
Author: User
Using C # Analog Web Landing, where to request a few pages, will initiate the corresponding HTTP request requests, where keepalive set to True, submit the request, then there will be a corresponding RESPONSE:RESP = (HttpWebResponse) req. GetResponse (); The previous debugging, has always been able to get the corresponding response, and then read the HTML page. But then several times debugging, without changing the code of the premise, the results of GetResponse will always die out. Resolution 1. The default request's timeout is 1000000 milliseconds = 100 seconds, all times out, manually to 10 seconds, so it's easier to time out and not solve the problem. 2. Setting the HTTP request's keepalive to false is still the problem. 3. To refer to: C # request. GetResponse (); Timeout problem resolution, and HttpWebRequest multithreaded performance problem, request timeout error, go to the previous total of 4 HttpRequest, each increment corresponding: resp = null; if (resp!= null) {resp. Close (); } if (req!= null) {req. Abort (); The result still doesn't solve the problem. 4. Also refer to: HttpWebRequest multithreading performance problem, request timeout error, to try the DefaultConnectionLimit settings, to 10: System.Net.ServicePointManager.DefaultConnectionLimit = 10; The problem remains. 5. Again to test the next, about response. Close () also does not solve the problem. 6. Finally inadvertently, simply do not hope, again defaultconnectionlimit set to a larger value 50:system.net.servicepointmanager.defaultconnectionlimit = 50; Try it out, the result is to solve the problem of timeout.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.