fsprojects / fsprojects/FsHttp

Port exhaustion regression

Open
#198 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
F#
Stars
498
Forks
41
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the default httpClientFactory behavior described in the issue and compare it with the change referenced in #37. Reproduce many requests to the same domain, ideally in the Azure Web App scenario, then verify the default behavior avoids creating a new client for every request and prevents the reported SNAT exhaustion.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.