When would you need to adjust these two settings (below)? And what do these two numbers mean for HttpWebRequest
instances that I make?
System.Net.ServicePointManager.DefaultConnectionLimit
System.Net.ServicePointManager.MaxServicePointIdleTime
Are ServicePoint
objects specific to a domain name or each unique URI requested?
The DefaultConnectionLimit property sets the default maximum number of concurrent connections that the ServicePointManager object assigns to the ConnectionLimit property when creating ServicePoint objects.
ServicePointManager is a static class used to create, maintain, and delete instances of the ServicePoint class.
HttpClient connections management in . NET Framework 4.5 and +, the default constructor of HttpClient uses the HttpClientHandler class, which leverages the HttpWebRequest class to send HTTP requests. Therefore, we can use the good old ServicePoint and ServicePointManager classes to manage opened connections.
When the ConnectionLeaseTimeout property is set to a value other than -1, and after the specified time elapses, an active ServicePoint connection is closed after servicing a request by setting KeepAlive to false in that request. Setting this value affects all connections managed by the ServicePoint object.
Here is a great explanation:
Understanding MaxServicePointIdleTime and DefaultConnectionLimit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With