The HttpClient Bug That Teaches a Lesson Every .NET Team Learns Eventually

Leader ●1 ●8 ●31
calendar_today • schedule1 min read

Real story from a large scale platform implementation, not a hypothetical.

We started seeing "Faulted" dependency calls in Application Insights — requests hanging for over a minute, then dying. Customers hitting timeouts on live API calls.

Root cause, once we traced it: HttpClient instances pulled from IHttpClientFactory were being wrapped in using blocks and disposed after every single call.

That one habit — copied from a hundred StackOverflow answers — was quietly closing pooled connections the factory was designed to keep alive, forcing new handlers to spin up under load, and exhausting the connection pool exactly when traffic spiked.

The fix wasn't clever. It was disciplined: → Stop disposing factory-managed clients → Replace blocking .GetAwaiter().GetResult() chains with real async → Right-size timeouts (120s → 30s) so failures surface fast instead of hanging → Tune SocketsHttpHandler pooling explicitly instead of trusting defaults

The best infrastructure lessons aren't abstract. They're "we found the bug in production, understood exactly why, and fixed the pattern everywhere it appeared" — not just the one call site that paged someone.

For more details read my other

post

Part 1 of 1 in Battle time stories

2 Comments

0 votes
0
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

The Zero-Net-Loss Fleet & The Mercenary Squad: A Live AI Economy

DEVPlank - Aug 4

Free SEO Tools Every Small Business Should Use (2026) | FloxoLab

floxolab - Oct 20

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Why Are There Only 13 DNS Root Servers For The Whole World? Is that a problem

richarddjarbeng - May 7

A Textile Mill's Dyehouse Ramp Curve: Get One Step Wrong and the Sheet Belongs to the Master

aiomniu - Oct 18
chevron_left
2.7k Points • 40 Badges
Karachi, Pakistan • linkedin.com/in/noumanberlas
15Posts
10Comments
23Connections
I design systems that scale and build the teams that ship them.

Over 18 years I've architected clo... Show more

Commenters (This Week)

1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!