Closed
Description
hello,
The following code will create httpclient every time you request it, and it is not explicitly released. In high concurrency scenarios, it may cause the tcp connection pool to be exhausted and new connections cannot be created. Is there any adjustment plan or other undiscovered processing to avoid long-term service exceptions
public HttpClient CreateClient(BoundConfiguration boundConfiguration)
{
if (boundConfiguration == null) throw new ArgumentNullException(nameof(boundConfiguration));
var key = HttpRequestInvoker.GetClientKey(boundConfiguration);
var handler = CreateHandler(key, boundConfiguration);
var client = new HttpClient(handler, disposeHandler: false)
{
Timeout = boundConfiguration.RequestTimeout
};
return client;
}
Official reference documents
https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines