Menu

1 / 2

Your HttpClient Retry Policy Probably Never Retried a Hung Request

DEV Community: dotnet·Ahmed Elbashier·10 days ago
#FPa1IVp3
#devtodotnet#devto#dev#timeout#retry
Long article (1266 words) — no AI summary yet.
Reading 0:00
15s threshold

A phone is ringing, and your service has a couple of seconds to look the caller up in the CRM so the agent sees a name instead of a bare number. The CRM's first request hangs. You have a retry policy with three retries and exponential backoff, so you expect the second attempt to save you. It never runs. The call is answered with no context, and the logs show one TaskCanceledException .

I found this pattern in my own public template, dotnet-integration-api-template . It sets http.Timeout = 10s on a typed HttpClient and adds a Polly retry with AddPolicyHandler . The retries work fine for fast failures (a 503, a refused connection). For a request that hangs , the whole 10 seconds goes to attempt one, and the retry loop is cancelled with it.

So I built a small lab to measure exactly what each common wiring does.

The setup

Every scenario uses the same fake upstream: attempt 1 hangs (30 s), and attempt 2 onwards answers 200 immediately.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.