Skip to main content

Practice ยท 3 of 4

Retry with Backoff

CHALLENGE
Difficulty: intermediate+25 XP

Implement GetWithRetryAsync: up to maxAttempts attempts; retry on 5xx responses and HttpRequestException; NEVER retry other statuses. Delay between attempts with backoff (baseMs << (attempt-1), capped at capMs โ€” the harness provides a fake async delay recorder). Return the first success; after exhausting attempts return "failed". ``csharp static Task<string> GetWithRetryAsync(HttpClient http, string path, int maxAttempts, int baseMs, int capMs, CancellationToken ct = default); ``

Back to lesson: Practice: HTTP Practice: Handlers, Outcomes, Retries