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

Port exhaustion regression #198

Open
ntwilson opened this issue Sep 6, 2024 · 1 comment
Open

Port exhaustion regression #198

ntwilson opened this issue Sep 6, 2024 · 1 comment

Comments

@ntwilson
Copy link

ntwilson commented Sep 6, 2024

Using FsHttp with the default httpClientFactory on an Azure Web App to send many HTTP requests to the same domain results in SNAT port exhaustion, with the error

System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

From what I can tell, this is because the default factory will create a new HttpClient instance for each request. Microsoft documentation states that if you are not using HttpClientFactory with DI, you should have a singleton HttpClient for the lifetime of your application to avoid the port exhaustion problem.

It looks like this problem was fixed in #37, but then reintroduced later.

@SchlenkR
Copy link
Owner

SchlenkR commented Sep 9, 2024

Thank you very much for submitting this issue. The problem here is that FsHttp allows per-request configuration of the underlying SocketsHttpHandler, which then results in a per-request instance of HttpClient. We could think about something like:

  • mark the per-instance httpClientHandlerTransformersand httpClientTransformers as obsolete, and change the behavior of the request generation in a way that if they are not used for a request, a per-process instance of the related SocketsHttpHandler, HttpClient, etc. are used.
  • allow a per-process default configuration of these 2 transformers.

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

2 participants