cck-httpclient-factory

Configure IHttpClientFactory with resilience handlers and DelegatingHandlers in .NET.

2|Updated Mar 31, 2026
One-click install
npx skills add https://github.com/s205109/AHKFlowApp --skill cck-httpclient-factory
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cck-httpclient-factory
Source: https://github.com/s205109/AHKFlowApp/tree/main/.claude/skills/cck-httpclient-factory
Command: npx skills add https://github.com/s205109/AHKFlowApp --skill cck-httpclient-factory

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about cck-httpclient-factory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my HttpClient cause socket exhaustion in .NET and how do I fix it?

HttpClient causes socket exhaustion when instantiated frequently or used as a singleton. Fix this by using IHttpClientFactory to manage handler lifetimes and ensure proper handler rotation in .NET applications.

How do I configure retries and circuit breakers for HttpClient in .NET 10?

Configure retries and circuit breakers for HttpClient in .NET 10 by applying AddStandardResilienceHandler. This provides timeouts, retries with jitter, circuit breaking, and rate limiting for external calls.

What is the best way to add authentication headers to HttpClient requests per request?

The best way to add per-request authentication headers is implementing DelegatingHandler. These handlers inject authentication, propagate correlation IDs, and manage headers without affecting the shared client configuration.

Can I use keyed HttpClient with dependency injection in .NET 10?

Yes, you can use keyed HttpClient in .NET 10 by configuring clients with AddAsKeyed. This allows resolving specific named or keyed clients from the dependency injection container.

How do I mock HttpClient for integration tests in .NET?

Mock HttpClient for integration tests by using mock HttpMessageHandler patterns. This provides deterministic test behavior without making actual network calls to external services.

When should I tune SocketsHttpHandler for HttpClient in .NET?

Tune SocketsHttpHandler when managing connection pooling and maximum connections. This optimizes HTTP client performance for high-throughput scenarios requiring precise network resource control.