What problem does it solve?
Misuse of HttpClient in .NET causes socket exhaustion, stale DNS resolution, inconsistent handler rotation, and brittle external calls without retries, timeouts, or circuit breaking; this Skill provides patterns to manage HttpClient lifetimes and add resilience consistently.
Core Features & Use Cases
- Managed HttpClient lifetimes: Use IHttpClientFactory, keyed clients, and AddAsKeyed to avoid socket exhaustion and ensure handler rotation.
- Resilience and policies: AddStandardResilienceHandler to provide timeouts, retries with jitter, circuit breaking, and rate limiting for robust external calls.
- Cross-cutting concerns via handlers: Use DelegatingHandler implementations for authentication injection, correlation ID propagation, and per-request header handling.
- Advanced tuning and testing: Configure SocketsHttpHandler for pooling and max connections and use mock HttpMessageHandler patterns for deterministic integration tests.
- Use Case: Build a production-ready API client to call third-party services with automatic retries, circuit breakers, idempotency safeguards, and testable behavior.
Quick Start
Configure a keyed HttpClient with AddAsKeyed and AddStandardResilienceHandler and add a DelegatingHandler for authentication to call your external API safely.