Request.GetResponse() timeout problem solution
Solution
1. Set keepAlive of http request to false //If keepalive is not necessary, then keepAlive is set to false:
2. Modify System.Net.ServicePointManager.DefaultConnectionLimit = 100; //This value is 2 by default
3. Release resources (such as HttpWebReques object and HttpWebResponse object)
if (resp != null)
{
resp.Close();
}
if (req != null)
{
req.Abort();
}
4. Before creating the HttpWebReques object, force garbage collection
System.GC.Collect();
5. Do not manually set the value of ContentLength when making Http GET request
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.