By default HttpClient only uses 2 concurrent connections per host. According to docs I can change that. I don't want to change it on a global level, I just want to change it for the service I'm using. Therefore I wrote the following code:
// Increase connection limit in order to have more concurrent requests to MyService
ServicePointManager.FindServicePoint(myServiceUrl, null).ConnectionLimit = 20;
Unfortunately, this doesn't work. The service (called via HttpClient) still uses only 2 concurrent connections. If I change the code to:
ServicePointManager.DefaultConnectionLimit = 20;
At the same code location, it works. However, I don't want to globally change this setting. How to change it locally only?
Edit: I realized that something is setting the connection limit back to 2. Is there any operation (e.g., instantiating a new WebRequestHandler, instantiating a new HttpClient, ...?) which resets the connection limit?
myServiceUrl
correspond to the actual service you're calling. – Gd