liveBook · Manning

Transient failure

As explained in ASP.NET Core in Action, 3e

A transient error is a temporary failure, such as a network or service interruption, that may succeed when the operation is retried.

A transient failure is a temporary problem, such as a network interruption, timeout, or temporarily unavailable remote service, that may succeed when the operation is retried. HTTP clients can handle these failures automatically so application code receives a successful result when possible. section 33.3 section 33.5

Handle transient HTTP failures by:

  • Adding the Microsoft.Extensions.Http.Polly package. section 33.3
  • Registering a named or typed HttpClient with AddTransientHttpErrorPolicy(). section 33.3 section 33.5
  • Choosing a retry policy and delays, while retrying only requests that are safe to repeat. section 33.3 section 33.5
  • Considering alternatives such as exponential backoff, circuit breakers, or failing quickly when retries are unlikely to help. section 33.3 section 33.5

Retrying a typed client request

builder.Services.AddHttpClient<ExchangeRatesClient>().AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(new[] { TimeSpan.FromMilliseconds(200), TimeSpan.FromMilliseconds(500), TimeSpan.FromSeconds(1) })); This policy retries three times after connection errors, server errors, or timeout responses, without requiring the caller to implement retry logic. section 33.5

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains causes, handler-pipeline placement, retry configuration, policy choices, and safety trade-offs without detailing Polly internals.
Examples
Uses remote API outages, network drops, timeouts, 5xx responses, and a typed exchange-rates client with three retry delays.
What it assumes
Assumes HTTP API calls and HttpClient usage while introducing handler pipelines and Polly-based resilience.
What you can do after
Configure automatic retries for transient HTTP failures through a named or typed HttpClient.
How it connects
Connects transient failure with HttpClient, IHttpClientFactory, Polly, retry policies, exponential backoff, and circuit breakers.

Also explained in

Compare how 2 books explain transient failure →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.