dotnet / dotnet/dotnet-api-docs
ServicePoint documentation missing important information
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
We are facing SNAT port exhaustion caused by excess of TCP connections from our application. In theory we could fix that by changing the value of [ServicePoint.ConnectionLimit](https://docs.microsoft.com/en-us/dotnet/api/system.net.servicepoint.connectionlimit), however when I see the [ServicePoint](https://docs.microsoft.com/en-us/dotnet/api/system.net.servicepoint) documentation ([last commit](https://github.com/dotnet/dotnet-api-docs/blob/44af8fae11e17449b9776ac7d90d0f51428ecd26/xml/System.Net/ServicePoint.xml) as of this write), I still have many questions:
* Does it apply to connections opened by `HttpClient`, `HttpWebRequest` or both? Any other client? I'm asking this because we use many libraries that perform HTTP requests without exposing how they do it (i.e. Azure Storage client, ADAL, etc).
* What is the URI matching algorithm? Are the URIs case-sensitive? Will the URIs `http://www.contoso.com` and `http://www.contoso.com:80` both use same instance of `ServicePoint`? Will `www.contoso.com:80` and `www.contoso.com:443` both use same instance?
* Or do you perform a DNS query for determining the `ServicePoint` from the target IP address? In other words, will multiple hostnames use same instance of `ServicePoint` if they have same IP address?
* Why do you have a note saying *"In high load conditions, some applications may run out of free threads in the ThreadPool, which may lead to poor system performance (such as high and variable transaction times)"* ??? Is there any direct relationship between `ServicePoint` and thread allocation?
* What happens when the number of connections is reached? Will classes like `HttpWebRequest` throw an exception clearly stating that? Or will they wait until a connection is available and therefore block current thread or put current `Task` in wait state?
For notice, I have searched documentation of related classes and methods (i.e. `HttpWebRequest`, `ServicePointManager.FindServicePoint`, etc) and they also don't explain.
The documentation should state this information, else it's hard to upgrade .NET Framework or migrate to .NET Core because certain changes in the behavior may cause outages.
Contributor guide
Research direction
Start with xml/System.Net/ServicePoint.xml and the related HttpWebRequest and ServicePointManager.FindServicePoint documentation mentioned in the issue. Verify the connection, URI matching, DNS, thread, and connection-limit behavior across the relevant .NET implementations, then document the answers and any version differences so the guidance is complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- documentation, networking
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100