httpclient-factory

Configure .NET HttpClient creation with IHttpClientFactory, resilience handlers, and DelegatingHandlers.

Updated Apr 27, 2026
One-click install
npx skills add https://github.com/shahdanish/vibepos --skill httpclient-factory-shahdanish
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: httpclient-factory
Source: https://github.com/shahdanish/vibepos/tree/main/skills/httpclient-factory
Command: npx skills add https://github.com/shahdanish/vibepos --skill httpclient-factory-shahdanish

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill solves the problems caused by misusing HTTP clients in .NET, including socket exhaustion, DNS change issues, and missing resilience (timeouts, retries, and circuit breakers) for external calls.

Core Features & Use Cases

  • IHttpClientFactory setup: Uses factory-managed HttpMessageHandler lifetimes instead of creating HttpClient per request, keeping applications stable under load.
  • Named and keyed/typed client patterns: Shows when to use named clients versus keyed clients in .NET 10 to avoid handler rotation issues.
  • Resilience with standard policies: Applies AddStandardResilienceHandler with rate limiting, total timeouts, retry/backoff, and circuit breaking for robust outbound HTTP.
  • DelegatingHandlers for cross-cutting concerns: Adds authentication headers and correlation IDs in a consistent pipeline rather than scattering logic across services.

Quick Start

Load this skill and then configure your HTTP client registrations with AddHttpClient plus AddStandardResilienceHandler, using keyed clients where appropriate, and attach any required DelegatingHandlers for auth or correlation IDs.

Frequently Asked Questions about httpclient-factory

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

FAQPage Schema
How do I prevent HttpClient socket exhaustion in .NET?

Use IHttpClientFactory to manage HttpMessageHandler lifetimes instead of creating new HttpClient instances per request, preventing socket exhaustion and keeping .NET applications stable under heavy load.

How do I add circuit breaker and retry policies to .NET HttpClient?

Add circuit breaker and retry policies to .NET HttpClient by applying AddStandardResilienceHandler during registration, which configures rate limiting, total timeouts, retry with backoff, and circuit breaking automatically.

When should I use keyed clients versus named clients in .NET 10?

Use keyed clients in .NET 10 when you need to avoid handler rotation issues associated with named clients, allowing precise dependency injection and safer external API integration for multiple endpoints.

How do I add authentication headers and correlation IDs to outbound HTTP requests in .NET?

Attach DelegatingHandlers to your IHttpClientFactory pipeline to consistently add authentication headers and correlation IDs to outbound HTTP requests, centralizing cross-cutting concerns rather than scattering logic across services.

Does IHttpClientFactory support DNS change resolution for long-lived .NET HTTP connections?

Yes, IHttpClientFactory supports DNS change resolution by rotating handler instances according to its managed lifetimes, solving connection staleness issues that occur when reusing a single static HttpClient.

What is the best way to configure resilient external API integrations in .NET?

The best way to configure resilient .NET API integrations is registering clients via AddHttpClient, applying AddStandardResilienceHandler for automatic fault tolerance, and composing DelegatingHandlers for cross-cutting request concerns.