Skip to content

[HTTP] ServicePointManager and ServicePoint#12423

Open
ManickaP wants to merge 4 commits intodotnet:mainfrom
ManickaP:sp-spm
Open

[HTTP] ServicePointManager and ServicePoint#12423
ManickaP wants to merge 4 commits intodotnet:mainfrom
ManickaP:sp-spm

Conversation

@ManickaP
Copy link
Member

Updated docs with more details about:

  • SetTcpKeepAlive
  • ConnectionLimit
  • MaxServicePoints

@ManickaP ManickaP requested a review from a team as a code owner March 19, 2026 15:48
Copilot AI review requested due to automatic review settings March 19, 2026 15:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the XML API docs for System.Net.ServicePointManager and System.Net.ServicePoint to clarify behavioral details around TCP keep-alives, connection limits, and the MaxServicePoints cap.

Changes:

  • Expanded MaxServicePoints remarks to describe behavior when the limit is exceeded.
  • Added thread-safety notes for SetTcpKeepAlive.
  • Added a note about ServicePoint.ConnectionLimit behavior with proxies.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
xml/System.Net/ServicePointManager.xml Clarifies MaxServicePoints behavior and documents SetTcpKeepAlive thread-safety considerations.
xml/System.Net/ServicePoint.xml Adds proxy-related note for ConnectionLimit and adds SetTcpKeepAlive thread-safety guidance.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Marie Píchová <11718369+ManickaP@users.noreply.github.com>
Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor suggestions.


The <xref:System.Net.ServicePoint.ConnectionLimit> property sets the maximum number of connections that the <xref:System.Net.ServicePoint> object can make to an Internet resource. The value of the <xref:System.Net.ServicePoint.ConnectionLimit> property is set to the value of the <xref:System.Net.ServicePointManager.DefaultConnectionLimit?displayProperty=nameWithType> property when the <xref:System.Net.ServicePoint> object is created; subsequent changes to <xref:System.Net.ServicePointManager.DefaultConnectionLimit> have no effect on existing <xref:System.Net.ServicePoint> objects.

The connection limit does not apply to proxied connections nor proxy tunnels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The connection limit does not apply to proxied connections nor proxy tunnels.
The connection limit doesn't apply to proxied connections or proxy tunnels.


## Remarks
When you reduce the <xref:System.Net.ServicePointManager.MaxServicePoints> property below the number of <xref:System.Net.ServicePoint> objects currently in existence, the <xref:System.Net.ServicePointManager> deletes the <xref:System.Net.ServicePoint> objects with the longest idle times. If the number of <xref:System.Net.ServicePoint> objects with active connections is greater than the value of <xref:System.Net.ServicePointManager.MaxServicePoints%2A>, the <xref:System.Net.ServicePointManager> object deletes the <xref:System.Net.ServicePoint> objects as they become idle.
When you reduce the <xref:System.Net.ServicePointManager.MaxServicePoints> property below the number of <xref:System.Net.ServicePoint> objects currently in existence, the <xref:System.Net.ServicePointManager> deletes the <xref:System.Net.ServicePoint> objects with the longest idle times. If the number of <xref:System.Net.ServicePoint> objects with active connections is greater than the value of <xref:System.Net.ServicePointManager.MaxServicePoints%2A>, the <xref:System.Net.ServicePointManager> object deletes the <xref:System.Net.ServicePoint> objects as they become idle. If this limit is set and more distinct <xref:System.Net.ServicePoint> instances are requested, <xref:System.Net.ServicePointManager.FindServicePoint%2A> will throw. As a result, <xref:System.Net.HttpWebRequest>s leading to new, distinct endpoints will fail.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When you reduce the <xref:System.Net.ServicePointManager.MaxServicePoints> property below the number of <xref:System.Net.ServicePoint> objects currently in existence, the <xref:System.Net.ServicePointManager> deletes the <xref:System.Net.ServicePoint> objects with the longest idle times. If the number of <xref:System.Net.ServicePoint> objects with active connections is greater than the value of <xref:System.Net.ServicePointManager.MaxServicePoints%2A>, the <xref:System.Net.ServicePointManager> object deletes the <xref:System.Net.ServicePoint> objects as they become idle. If this limit is set and more distinct <xref:System.Net.ServicePoint> instances are requested, <xref:System.Net.ServicePointManager.FindServicePoint%2A> will throw. As a result, <xref:System.Net.HttpWebRequest>s leading to new, distinct endpoints will fail.
When you reduce the <xref:System.Net.ServicePointManager.MaxServicePoints> property below the number of <xref:System.Net.ServicePoint> objects currently in existence, the <xref:System.Net.ServicePointManager> deletes the <xref:System.Net.ServicePoint> objects with the longest idle times. If the number of <xref:System.Net.ServicePoint> objects with active connections is greater than the value of <xref:System.Net.ServicePointManager.MaxServicePoints%2A>, the <xref:System.Net.ServicePointManager> object deletes the <xref:System.Net.ServicePoint> objects as they become idle. If this limit is set and more distinct <xref:System.Net.ServicePoint> instances are requested, <xref:System.Net.ServicePointManager.FindServicePoint%2A> will throw. As a result, <xref:System.Net.HttpWebRequest> requests leading to new, distinct endpoints will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants