<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged httpclient</title>
<link>https://coderlegion.com/tag/httpclient</link>
<description>Powered by Question2Answer</description>
<item>
<title>The HttpClient Bug That Teaches a Lesson Every .NET Team Learns Eventually</title>
<link>https://coderlegion.com/25445/the-httpclient-bug-that-teaches-a-lesson-every-net-team-learns-eventually</link>
<description>&lt;p&gt;Real story from a large scale platform implementation, not a hypothetical.&lt;/p&gt;
&lt;p&gt;We started seeing &quot;Faulted&quot; dependency calls in Application Insights — requests hanging for over a minute, then dying. Customers hitting timeouts on live API calls.&lt;/p&gt;
&lt;p&gt;Root cause, once we traced it: HttpClient instances pulled from IHttpClientFactory were being wrapped in using blocks and disposed after every single call.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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&lt;/p&gt;
&lt;p&gt;The best infrastructure lessons aren't abstract. They're &quot;we found the bug in production, understood exactly why, and fixed the pattern everywhere it appeared&quot; — not just the one call site that paged someone.&lt;/p&gt;
&lt;p&gt;For more details read my other &lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://coderlegion.com/25280/httpclient-socket-exhaustion&quot;&gt;post&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/25445/the-httpclient-bug-that-teaches-a-lesson-every-net-team-learns-eventually</guid>
<pubDate>Wed, 26 Aug 2026 15:19:19 +0000</pubDate>
</item>
</channel>
</rss>