microsoft-authentication-library-for-dotnet
microsoft-authentication-library-for-dotnet copied to clipboard
[Feature Request] Better default HTTPClient on .NET Core
trafficstars
MSAL's default HttpClient does not handle DNS changes.
Proposal: use System.Net.Http.SocketsHttpHandler on confidential client flows
The configuration should be similar to
#if NETCOREAPP2_1_OR_GREATER
// Starting with netcore2.1 and .NET5+, HttpClient maintains long lived socket connections and as a result does
// not respect DNS. This enforces a reconnect and as a result a DNS update.
var handler = new SocketsHttpHandler { PooledConnectionLifetime = TimeSpan.FromMinutes(15) };
HttpClient = new HttpClient(handler) { Timeout = timeout, MaxResponseContentBufferSize = maxResponseDataSize };
#else
HttpClient = new HttpClient() { Timeout = timeout, MaxResponseContentBufferSize = maxResponseDataSize };
#endif
@pmaytak - based on error telemetry, is this worth doing?
Based on the error telemetry - no, low ROI because errors are only a tiny amount of total requests. They do say there's perf improvement, so I would do it for general perf improvements. Maybe a P3?