Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Prevent HttpClient port exhaustion #1756

Closed
bgavrilMS opened this issue Apr 9, 2020 · 3 comments
Closed

[Feature Request] Prevent HttpClient port exhaustion #1756

bgavrilMS opened this issue Apr 9, 2020 · 3 comments
Assignees
Milestone

Comments

@bgavrilMS
Copy link
Member

bgavrilMS commented Apr 9, 2020

Which Version of MSAL are you using ?
4.11

Platform
net45, netcore

Affects confidential clients

Repro

  1. Do not provide a custom IHttpFactory
  2. Many threads AcquireToken (e.g. web site at scale)

Expected behavior
MSAL should work

Actual behavior
After some time, an exception from HttpClient occurs complaining about port exaustion.

Possible Solution
There is a solution on .net classic described here https://softwareengineering.stackexchange.com/questions/330364/should-we-create-a-new-single-instance-of-httpclient-for-all-requests

For .net core, the solution is to use IHttpClientFactory, which needs to be adapted. Microsoft.Identity.Web should showcase how to do this. A better default for MSAL needs some investigation.

@bgavrilMS bgavrilMS changed the title [Bug] Prevent HttpClient port exhaustion on .net classic [Feature Request] Prevent HttpClient port exhaustion on .net classic Apr 9, 2020
@bgavrilMS bgavrilMS self-assigned this Apr 9, 2020
@henrik-me
Copy link
Contributor

@bgavrilMS, regarding .netcore, are there somethings we can do better by default in the library (and perhaps will make it easier for Identity.Web and others to do the right thing and or their custom thing)?

@bgavrilMS
Copy link
Member Author

I'll have a look at this. We could add a simplified version of IHttpClientFactory, or even a static HttpClient.

@bgavrilMS bgavrilMS changed the title [Feature Request] Prevent HttpClient port exhaustion on .net classic [Feature Request] Prevent HttpClient port exhaustion Apr 14, 2020
@bgavrilMS bgavrilMS added this to the 4.16.0 milestone Jun 22, 2020
@jmprieur
Copy link
Contributor

jmprieur commented Jul 7, 2020

See Azure-Samples/ms-identity-aspnet-webapp-openidconnect#38 for how the usage of SuggestedCacheKey and HasToken simplifies the token cache serialization in confidential client applications

cc: @bgavrilMS @jennyf19 @pmaytak @henrik-me @trwalke @neha-bhargava

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants