Last updated: October 8, 2026 · Tested with .NET 10 (SDK 10.0.401, runtime 10.0.12), Microsoft.Extensions.Http.Resilience 10.10.0 (Polly.Core 8.4.2), Windows 11 Short answer: don't create a new HttpClient() per request. Get clients from IHttpClientFactory ( AddHttpClient , named or typed), or keep one static HttpClient on a long-lived SocketsHttpHandler with PooledConnectionLifetime set so DNS changes are picked up. For retries and timeouts add AddStandardResilienceHandler() from Microsoft.Extensions.Http.Resilience and let it own the timeouts. Below is what I measured against a local Kestrel test server: 2,000 sockets left in TIME_WAIT by the per-request pattern, the exact timeout exceptions, real retry logs, a measured Retry-After delay, and one surprise: the standard handler silently replaces your HttpClient.Timeout . The Test Setup All examples run as console apps against a minimal API on http://127.0.0.1:5199 in the same solution. It has endpoints that answer f...
CSharp-Coder.com is a free online resource dedicated to helping both beginner and advanced developers learn and improve their programming skills. The website offers a variety of tutorials, articles, and resources designed to make learning programming easy and fun.