Revise content on the reconnection UI delay (#32237)
parent
048c63cc33
commit
72aabbde2a
|
@ -1113,24 +1113,37 @@ For more information on Blazor startup, see <xref:blazor/fundamentals/startup>.
|
|||
|
||||
:::moniker range=">= aspnetcore-6.0"
|
||||
|
||||
## Delay the appearance of the reconnection UI
|
||||
## Control when the reconnection UI appears
|
||||
|
||||
If a deployed app frequently displays the reconnection UI due to ping timeouts caused by Internet latency, lengthen the server and client timeouts:
|
||||
Controlling when the reconnection UI appears can be useful in the following situations:
|
||||
|
||||
* A deployed app frequently displays the reconnection UI due to ping timeouts caused by internal network or Internet latency, and you would like to increase the delay.
|
||||
* An app should report to users that the connection has dropped sooner, and you would like to shorten the delay.
|
||||
|
||||
The timing of the appearance of the reconnection UI is influenced by adjusting the Keep-Alive interval and timeouts on the client. However, changing a setting may require changes to other Keep-Alive, timeout, and handshake settings.
|
||||
|
||||
As general recommendations for the guidance that follows:
|
||||
|
||||
* The Keep-Alive interval should match between client and server configurations.
|
||||
* Timeouts should be at least double the value assigned to the Keep-Alive interval.
|
||||
|
||||
### Server configuration
|
||||
|
||||
:::moniker-end
|
||||
Set the following:
|
||||
|
||||
:::moniker range=">= aspnetcore-8.0"
|
||||
* <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> (default: 30 seconds): The time window clients have to send a message before the server closes the connection.
|
||||
* <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> (default: 15 seconds): The interval used by the server to timeout incoming handshake requests by clients.
|
||||
* <xref:Microsoft.AspNetCore.SignalR.HubOptions.KeepAliveInterval> (default: 15 seconds): The interval used by the server to send keep alive pings to connected clients. Note that there is also a Keep-Alive interval setting on the client, which should match the server's value.
|
||||
|
||||
At least double the maximum roundtrip time expected between the client and the server. Test, monitor, and revise the timeouts as needed. For the SignalR hub, set the <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> (default: 30 seconds) and <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> (default: 15 seconds). The following example assumes that <xref:Microsoft.AspNetCore.SignalR.HubOptions.KeepAliveInterval> uses the default value of 15 seconds.
|
||||
The <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> and <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> can be increased, and the <xref:Microsoft.AspNetCore.SignalR.HubOptions.KeepAliveInterval> can remain the same. The important consideration is that if you change the values, make sure that the timeouts are at least double the value of the Keep-Alive interval and that the Keep-Alive interval matches between server and client. For more information, see the [Configure SignalR timeouts and Keep-Alive on the client](#configure-signalr-timeouts-and-keep-alive-on-the-client) section.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If the reconnection UI appearance issue is due to timeouts, the <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> and <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> can be increased and the Keep-Alive interval can remain the same. The important consideration is that if you change the Keep-Alive interval, make sure that the client timeout value is at least double the value of the Keep-Alive interval and that the Keep-Alive interval on the client matches the server setting.
|
||||
>
|
||||
> In the following example, the <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> is increased to 60 seconds, and the <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> is increased to 30 seconds.
|
||||
In the following example:
|
||||
|
||||
In the server project's `Program.cs` file:
|
||||
* The <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> is increased to 60 seconds (default value: 30 seconds).
|
||||
* The <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> is increased to 30 seconds (default value: 15 seconds).
|
||||
* The <xref:Microsoft.AspNetCore.SignalR.HubOptions.KeepAliveInterval> isn't set in developer code and uses its default value of 15 seconds. Decreasing the value of the Keep-Alive interval increases the frequency of communication pings, which increases the load on the app, server, and network. Care must be taken to avoid introducing poor performance when lowering the Keep-Alive interval.
|
||||
|
||||
**Blazor Web App** (.NET 8 or later) in the server project's `Program` file:
|
||||
|
||||
```csharp
|
||||
builder.Services.AddRazorComponents().AddInteractiveServerComponents()
|
||||
|
@ -1141,20 +1154,7 @@ builder.Services.AddRazorComponents().AddInteractiveServerComponents()
|
|||
});
|
||||
```
|
||||
|
||||
For more information, see the [Server-side circuit handler options](#server-side-circuit-handler-options) section.
|
||||
|
||||
:::moniker-end
|
||||
|
||||
:::moniker range=">= aspnetcore-6.0 < aspnetcore-8.0"
|
||||
|
||||
At least double the maximum roundtrip time expected between the client and the server. Test, monitor, and revise the timeouts as needed. For the SignalR hub, set the <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> (default: 30 seconds) and <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> (default: 15 seconds). The following example assumes that <xref:Microsoft.AspNetCore.SignalR.HubOptions.KeepAliveInterval> uses the default value of 15 seconds.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If the reconnection UI appearance issue is due to timeouts, the <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> and <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> can be increased and the Keep-Alive interval can remain the same. The important consideration is that if you change the Keep-Alive interval, make sure that the client timeout value is at least double the value of the Keep-Alive interval and that the Keep-Alive interval on the client matches the server setting.
|
||||
>
|
||||
> In the following example, the <xref:Microsoft.AspNetCore.SignalR.HubOptions.ClientTimeoutInterval> is increased to 60 seconds, and the <xref:Microsoft.AspNetCore.SignalR.HubOptions.HandshakeTimeout> is increased to 30 seconds.
|
||||
|
||||
In `Program.cs`:
|
||||
**Blazor Server** in the `Program` file:
|
||||
|
||||
```csharp
|
||||
builder.Services.AddServerSideBlazor()
|
||||
|
@ -1167,28 +1167,25 @@ builder.Services.AddServerSideBlazor()
|
|||
|
||||
For more information, see the [Server-side circuit handler options](#server-side-circuit-handler-options) section.
|
||||
|
||||
:::moniker-end
|
||||
|
||||
:::moniker range=">= aspnetcore-6.0"
|
||||
|
||||
### Client configuration
|
||||
|
||||
:::moniker-end
|
||||
|
||||
:::moniker range=">= aspnetcore-8.0"
|
||||
|
||||
Typically, double the value used for the server's <xref:Microsoft.AspNetCore.SignalR.HubOptions.KeepAliveInterval> to set the timeout for the client's server timeout (`withServerTimeout` or <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout>, default: 30 seconds).
|
||||
Set the following:
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If the reconnection UI appearance issue is due to timeouts, the server timeout can be increased and the Keep-Alive interval can remain the same. The important consideration is that if you change the Keep-Alive interval, make sure that the timeout value is at least double the value of the Keep-Alive interval and that the Keep-Alive interval on the server matches the client setting.
|
||||
>
|
||||
> In the following example, a custom value of 60 seconds is used for the server timeout.
|
||||
* `withServerTimeout` (default: 30 seconds): Configures the server timeout, specified in milliseconds, for the circuit's hub connection.
|
||||
* `withKeepAliveInterval` (default: 15 seconds): The interval, specified in milliseconds, at which the connection sends Keep-Alive messages.
|
||||
|
||||
In the [startup configuration](xref:blazor/fundamentals/startup) of a server-side Blazor app after the Blazor script (`blazor.*.js`) `<script>` tag.
|
||||
The server timeout can be increased, and the Keep-Alive interval can remain the same. The important consideration is that if you change the values, make sure that the server timeout is at least double the value of the Keep-Alive interval and that the Keep-Alive interval values match between server and client. For more information, see the [Configure SignalR timeouts and Keep-Alive on the client](#configure-signalr-timeouts-and-keep-alive-on-the-client) section.
|
||||
|
||||
In the following [startup configuration](xref:blazor/fundamentals/startup) example ([location of the Blazor script](xref:blazor/project-structure#location-of-the-blazor-script)), a custom value of 60 seconds is used for the server timeout. The Keep-Alive interval (`withKeepAliveInterval`) isn't set and uses its default value of 15 seconds.
|
||||
|
||||
Blazor Web App:
|
||||
|
||||
```html
|
||||
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
|
||||
<script>
|
||||
Blazor.start({
|
||||
circuit: {
|
||||
|
@ -1203,6 +1200,7 @@ Blazor Web App:
|
|||
Blazor Server:
|
||||
|
||||
```html
|
||||
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
|
||||
<script>
|
||||
Blazor.start({
|
||||
configureSignalR: function (builder) {
|
||||
|
@ -1212,9 +1210,9 @@ Blazor Server:
|
|||
</script>
|
||||
```
|
||||
|
||||
When creating a hub connection in a component, set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout> (default: 30 seconds) on the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder>. Set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeTimeout> (default: 15 seconds) on the built <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>.
|
||||
When creating a hub connection in a component, set the server timeout (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilderExtensions.WithServerTimeout%2A>, default: 30 seconds) on the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder>. Set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeTimeout> (default: 15 seconds) on the built <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>. Confirm that the timeouts are at least double the Keep-Alive interval (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilderExtensions.WithKeepAliveInterval%2A>/<xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.KeepAliveInterval>) and that the Keep-Alive value matches between server and client.
|
||||
|
||||
The following example is based on the `Index` component in the [SignalR with Blazor tutorial](xref:blazor/tutorials/signalr-blazor). The server timeout is increased to 60 seconds, and the handshake timeout is increased to 30 seconds:
|
||||
The following example is based on the `Index` component in the [SignalR with Blazor tutorial](xref:blazor/tutorials/signalr-blazor). The server timeout is increased to 60 seconds, and the handshake timeout is increased to 30 seconds. The Keep-Alive interval isn't set and uses its default value of 15 seconds.
|
||||
|
||||
```csharp
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
@ -1236,12 +1234,14 @@ protected override async Task OnInitializedAsync()
|
|||
|
||||
:::moniker range=">= aspnetcore-6.0 < aspnetcore-8.0"
|
||||
|
||||
Typically, double the value used for the server's <xref:Microsoft.AspNetCore.SignalR.HubOptions.KeepAliveInterval> to set the timeout for the client's server timeout (`serverTimeoutInMilliseconds` or <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout>, default: 30 seconds).
|
||||
Set the following:
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If the reconnection UI appearance issue is due to timeouts, the server timeout can be increased and the Keep-Alive interval can remain the same. The important consideration is that if you change the Keep-Alive interval, make sure that the timeout value is at least double the value of the Keep-Alive interval and that the Keep-Alive interval on the server matches the client setting.
|
||||
>
|
||||
> In the following example, a custom value of 60 seconds is used for the server timeout.
|
||||
* `serverTimeoutInMilliseconds` (default: 30 seconds): Configures the server timeout, specified in milliseconds, for the circuit's hub connection.
|
||||
* `keepAliveIntervalInMilliseconds` (default: 15 seconds): The interval, specified in milliseconds, at which the connection sends Keep-Alive messages.
|
||||
|
||||
The server timeout can be increased, and the Keep-Alive interval can remain the same. The important consideration is that if you change the values, make sure that the server timeout is at least double the value of the Keep-Alive interval and that the Keep-Alive interval values match between server and client. For more information, see the [Configure SignalR timeouts and Keep-Alive on the client](#configure-signalr-timeouts-and-keep-alive-on-the-client) section.
|
||||
|
||||
In the following [startup configuration](xref:blazor/fundamentals/startup) example ([location of the Blazor script](xref:blazor/project-structure#location-of-the-blazor-script)), a custom value of 60 seconds is used for the server timeout. The Keep-Alive interval (`keepAliveIntervalInMilliseconds`) isn't set and uses its default value of 15 seconds.
|
||||
|
||||
In `Pages/_Host.cshtml`:
|
||||
|
||||
|
@ -1260,9 +1260,9 @@ In `Pages/_Host.cshtml`:
|
|||
</script>
|
||||
```
|
||||
|
||||
When creating a hub connection in a component, set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout> (default: 30 seconds) and <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeTimeout> (default: 15 seconds) on the built <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>.
|
||||
When creating a hub connection in a component, set the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout> (default: 30 seconds) and <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeTimeout> (default: 15 seconds) on the built <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>. Confirm that the timeouts are at least double the Keep-Alive interval. Confirm that the Keep-Alive interval matches between server and client.
|
||||
|
||||
The following example is based on the `Index` component in the [SignalR with Blazor tutorial](xref:blazor/tutorials/signalr-blazor). The server timeout is increased to 60 seconds, and the handshake timeout is increased to 30 seconds:
|
||||
The following example is based on the `Index` component in the [SignalR with Blazor tutorial](xref:blazor/tutorials/signalr-blazor). The <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout> is increased to 60 seconds, and the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeTimeout> is increased to 30 seconds. The Keep-Alive interval (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.KeepAliveInterval>) isn't set and uses its default value of 15 seconds.
|
||||
|
||||
```csharp
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
@ -1282,17 +1282,6 @@ protected override async Task OnInitializedAsync()
|
|||
|
||||
:::moniker-end
|
||||
|
||||
:::moniker range=">= aspnetcore-6.0"
|
||||
|
||||
When changing the values of the server timeout (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.ServerTimeout>) or the Keep-Alive interval (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnection.KeepAliveInterval>):
|
||||
|
||||
* The server timeout should be at least double the value assigned to the Keep-Alive interval.
|
||||
* The Keep-Alive interval should be less than or equal to half the value assigned to the server timeout.
|
||||
|
||||
For more information, see the [Configure SignalR timeouts and Keep-Alive on the client](#configure-signalr-timeouts-and-keep-alive-on-the-client) section.
|
||||
|
||||
:::moniker-end
|
||||
|
||||
:::moniker range=">= aspnetcore-5.0"
|
||||
|
||||
## Disconnect the Blazor circuit from the client
|
||||
|
|
|
@ -59,7 +59,7 @@ A console warning appears if Long Polling is utilized:
|
|||
Recommendations for global deployments to geographical data centers:
|
||||
|
||||
* Deploy the app to the regions where most of the users reside.
|
||||
* Take into consideration the increased latency for traffic across continents. To delay the appearance of the reconnection UI, see <xref:blazor/fundamentals/signalr#delay-the-appearance-of-the-reconnection-ui>.
|
||||
* Take into consideration the increased latency for traffic across continents. To control the appearance of the reconnection UI, see <xref:blazor/fundamentals/signalr#control-when-the-reconnection-ui-appears>.
|
||||
* For Azure hosting, use the [Azure SignalR Service](#azure-signalr-service).
|
||||
|
||||
:::moniker-end
|
||||
|
|
Loading…
Reference in New Issue