diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index f2995a4d8ac7..9e5c66d3627e 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -1127,6 +1127,42 @@ Blazor Server: **In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.** For the location of the script and the path to use, see . +:::moniker range=">= aspnetcore-9.0" + +When the user navigates back to an app with a disconnected circuit, reconnection is attempted immediately rather than waiting for the duration of the next reconnect interval. This behavior seeks to resume the connection as quickly as possible for the user. + +The default reconnect timing uses a computed backoff strategy. The first several reconnection attempts occur in rapid succession before computed delays are introduced between attempts. The default logic for computing the retry interval is an implementation detail subject to change without notice, but you can find the default logic that the Blazor framework uses [in the `computeDefaultRetryInterval` function (reference source)](https://github.com/search?q=repo%3Adotnet%2Faspnetcore%20computeDefaultRetryInterval&type=code). + +[!INCLUDE[](~/includes/aspnetcore-repo-ref-source-links.md)] + +Customize the retry interval behavior by specifying a function to compute the retry interval. In the following exponential backoff example, the number of previous reconnection attempts is multiplied by 1,000 ms to calculate the retry interval. When the count of previous attempts to reconnect (`previousAttempts`) is greater than the maximum retry limit (`maxRetries`), `null` is assigned to the retry interval (`retryIntervalMilliseconds`) to cease further reconnection attempts: + +```javascript +Blazor.start({ + circuit: { + reconnectionOptions: { + retryIntervalMilliseconds: (previousAttempts, maxRetries) => + previousAttempts >= maxRetries ? null : previousAttempts * 1000 + }, + }, +}); +``` + +An alternative is to specify the exact sequence of retry intervals. After the last specified retry interval, retries stop because the `retryIntervalMilliseconds` function returns `undefined`: + +```javascript +Blazor.start({ + circuit: { + reconnectionOptions: { + retryIntervalMilliseconds: + Array.prototype.at.bind([0, 1000, 2000, 5000, 10000, 15000, 30000]), + }, + }, +}); +``` + +:::moniker-end + For more information on Blazor startup, see . :::moniker range=">= aspnetcore-6.0"