Head0nF1re
Head0nF1re
CC#
Created by Head0nF1re on 1/22/2023 in #help
❔ HttpClient vs IHttpClientFactory
Hey. I have a few doubts regarding HttpClient, I was reading: - 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 And I was wondering why the 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
177 replies