xmlresolver / xmlresolvercs

A C# implementation of the XML Resolver
Other
4 stars 3 forks source link

Reuse of HttpClient object #73

Closed michaelhkay closed 2 months ago

michaelhkay commented 2 months ago

I note that ResourceAccess.cs creates a new HttpClient object on each resource request, whereas the recommended advice is to create a shared HttpClient object and use it repeatedly: see https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-net-http-httpclient

If you instantiate an HttpClient class for every request, the number of sockets available under heavy loads will be exhausted. This exhaustion will result in SocketException errors.