-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Description
The default SearchClient
implementation for the .Net client does not follow the HttpClient
guidelines and exposes the user to either exhausting the TCP port of the computer or have stale DNS resolution in case of a changes in the Algolia DNS.
- An application using the
SearchClient
by instantiating it for each query will risk causing TCP port exhaustion on the computer on which it runs. - An application using it as a singleton will miss any DNS update that may occur on Algolia side.
(And there is no guidance on the "Get started" page about the intended lifecycle for the client.)
We can implement our own Algolia IHttpRequester
as a work around, but it would be better for the default implementation to be reliable "out of the box", at least with some usage guidelines.
Language
CSharp
Client
Search
Steps to reproduce
private readonly HttpClient _httpClient = new(
new TimeoutHandler
{
InnerHandler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip }
});
So, that is a HttpClient creation, ultimately, for each instance of SearchClient
, using neither a SocketsHttpHandler
with a configured PooledConnectionLifetime
nor an IHttpClientFactory
. The former is required for using the SearchClient
as a singleton while avoiding stale DNS resolution. The later is required for using the SearchClient
by instantiating it for each usage while avoiding TCP port exhaustion.
Relevant log output
No response
Self-service
- I'd be willing to fix this bug myself.