Request. GetResponse (); timeout problem resolution, and HttpWebRequest multithreading performance problems, request timeout errors,
Solution
1. Set the keepAlive of the http request to false // if it is not required to keepalive, set KeepAlive to false:
2. Modify System. Net. ServicePointManager. DefaultConnectionLimit = 50; // The default value is 2, which can be modified as needed.
3. release resources (such as HttpWebReques objects and HttpWebResponse objects)
If (resp! = Null)
{
Resp. Close ();
}
If (req! = Null)
{
Req. Abort ();
}
4. Force garbage collection before creating an HttpWebReques object
System. GC. Collect ();
5. Do not manually set the ContentLength value for Http GET requests.
In the POST method, it is indeed necessary to manually fill in the data and calculate the data size, and then manually assign a value to ContentLength.