You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HttpClient is intended to be instantiated once and reused throughout the life of an application. The following conditions can result in SocketException errors:
Creating a new HttpClient instance per request.
Server under heavy load.
Creating a new HttpClient instance per request can exhaust the available sockets.
I'd recommend that the class itself is disposable and cleans itself up, as well as a second option which is having the ctor take an HttpClient as a dependency.
I'm more than happy to provide a PR for this change.
The text was updated successfully, but these errors were encountered:
It appears the httpClient is disposed via using statement each time a request is processed.
https://github.com/chadly/Geocoding.net/blob/master/src/Geocoding.Google/GoogleGeocoder.cs#L164
This should not be happening and the httpClient should be reused.
https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client
I'd recommend that the class itself is disposable and cleans itself up, as well as a second option which is having the ctor take an HttpClient as a dependency.
I'm more than happy to provide a PR for this change.
The text was updated successfully, but these errors were encountered: