You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ff35c32
Browse filesBrowse the repository at this point in the historyBrowse files
fix: HttpClients created by HttpClientFactory.CreateHttpClient (including the shared static clients) now replace pooled connections every 2 minutes, so long-running processes pick up DNS changes
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@
4
4
5
5
* fix: ForceClient, JsonClient and AuthenticationClient no longer dispose an HttpClient passed in by the caller - the caller owns it
6
6
* fix: AuthenticationClient now uses a shared static HttpClient by default, like ForceClient and JsonClient, instead of creating a new HttpClient (and connection pool) per instance - repeated logins no longer leak sockets
7
+
* fix: HttpClients created by HttpClientFactory.CreateHttpClient (including the shared static clients) now replace pooled connections every 2 minutes, so long-running processes pick up DNS changes
8
+
- .NET 8+: uses SocketsHttpHandler with PooledConnectionLifetime (except on browser and mobile platforms, which keep their native handler)
9
+
- .NET Framework: sets ServicePoint.ConnectionLeaseTimeout for each request's host
The caller owns an `HttpClient` passed in this way - disposing `ForceClient`, `JsonClient` or `AuthenticationClient` does not dispose it, so a single long-lived instance can be shared across clients.
126
+
The caller owns an `HttpClient` passed in this way - disposing `ForceClient`, `JsonClient` or `AuthenticationClient` does not dispose it, so a single long-lived instance can be shared across clients. Clients built by `HttpClientFactory.CreateHttpClient` periodically replace their pooled connections so DNS changes are picked up; if you build your own `HttpClient`, configure that yourself (e.g. `SocketsHttpHandler.PooledConnectionLifetime`).
/// On browser and mobile platforms HttpClientHandler wraps the platform's native handler, which manages its own connections - keep it there.
100
+
/// </summary>
101
+
privatestaticboolUseSocketsHttpHandler()
102
+
{
103
+
returnSocketsHttpHandler.IsSupported
104
+
&&!OperatingSystem.IsAndroid()
105
+
&&!OperatingSystem.IsIOS()
106
+
&&!OperatingSystem.IsTvOS()
107
+
&&!OperatingSystem.IsMacCatalyst();
108
+
}
109
+
#endif
110
+
111
+
#if NETFRAMEWORK
112
+
/// <summary>
113
+
/// On .NET Framework, HttpClientHandler connections are managed by ServicePoint, which keeps them open indefinitely by default.
114
+
/// <para>Sets a connection lease timeout on the ServicePoint for each request's host, so connections are periodically replaced and DNS changes are picked up.</para>
0 commit comments