As the title says I'd like to disable the pipelining functionality BUT still make use of the connection pool (so KeepAlive=False is not an option). The reason is that longer requests may prevent shorter requests from executing fast, but opening up a new connection for every requests is significantly slower.
I'm doing this:
_webRequestHandler = new WebRequestHandler();
_webRequestHandler.AllowPipelining = false;
_httpClient = new HttpClient(_webRequestHandler);
await _httpClient.SendAsync(request);
servicePoint = ServicePointManager.FindServicePoint(request.RequestUri);
This seems to have no effect: The ServicePoint.SupportsPipelining property is still true and the WebRequestHandler is only setting the Pipelined property of the HttpWebRequest but nothing on the HttpRequestMessage so basically setting AllowPipelining on the WebRequestHandler has no effect (?).
Am I missing something here? I'm sure this is a common scenario - how can I achieve that?
The situation remains:
But it seems this can not be set this way, at least I couldn't find it and no one could help me. And expecting MS to fix the real problem is... well, unlikely.
So I ended up setting the ConnectionLimit to 1000 which seems to be high enough that the problem never occurrs (in our system). Not a real fix though - feel free to post if you have a better solution...