❔ HttpClient vs IHttpClientFactory
Hey. I have a few doubts regarding HttpClient, I was reading:
Also, in the context of a pulling service I assume that what I need is
I'm thinking in having a singleton
Thanks
- https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines
- https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory#httpclient-lifetime-management
IHttpClientFactory should only be used for short-lived connections (and what can be considered short-lived, like a few requests between a request flow?) ? Also, in the context of a pulling service I assume that what I need is
HttpClient without IHttpClientFactory (and configure PooledConnectionLifetime to prevent DNS problems) since it's requesting the same endpoint frequently, right? I'm thinking in having a singleton
SomeServiceHttpClient for each endpoint being used in the pulling service. Is there a difference in having it static or as singleton, I kept seeing posts about people having DNS issues with it being singleton?Thanks