ActiveLogin / ActiveLogin.Authentication

Support Swedish BankID (svenskt BankID) authentication in .NET. Unofficial package, not created by BankID.
https://activelogin.net
MIT License
216 stars 75 forks source link

Upgrade to HttpClientFactory #403

Closed PeterLevanderAtKnowit closed 1 year ago

PeterLevanderAtKnowit commented 1 year ago

In situations of high load, ActiveLogin overload and terminate all sockets, leading to the persistence of SocketExceptions for a prolonged period. This situation poses significant problems as resetting the app pool is the only viable solution, leading to a prolonged outage that denies customers access to the system.

However, migrating from HttpClient to HttpClientFactory may be a viable solution to address this issue. As of Core 2.0, HttpClientFactory is recommended for use instead of HttpClient. HttpClientFactory provides more efficient resource management and connection pooling capabilities that can mitigate the occurrence of SocketExceptions in situations of high load. Therefore, it is recommended that you evaluate migrating from HttpClient to HttpClientFactory to ensure the stability and scalability of your application.

PeterOrneholm commented 1 year ago

Thank you for the feedback Peter!

Do you have more details on how/what you are using? It would be great if you could provide the answers to the questions that we have in our Feature issue template.

In general, I believe we should be following the pattern you are mentioning, but I'm more than happy to improve this if you disagree :)

It is correct that we only accept an HttpClient as part of the constructor to the BankIdApiClient. This should still use HttpClientFactory from DI, we configure it here. TypedClients is the pattern we are using. If you don't use our Core package, and only our API-package, you need to follow the same pattern.

And as previous stated, if we've got this wrong and have more specific feedback on what we can improve, I'de be more than happy to hear.

PeterOrneholm commented 1 year ago

Closing this until we have more context.