From 91561fdc5049184ebfef046c4d5f956ecfaf8228 Mon Sep 17 00:00:00 2001 From: wadepickett Date: Tue, 24 Oct 2023 16:03:35 -0700 Subject: [PATCH 01/11] 8.0 Update: SignalR Config: stateful reconnect --- aspnetcore/signalr/configuration.md | 58 ++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index 6d1c1e3443fa..64fc90b3091f 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -5,7 +5,7 @@ description: Learn how to configure ASP.NET Core SignalR apps. monikerRange: '>= aspnetcore-2.1' ms.author: bradyg ms.custom: mvc -ms.date: 07/10/2023 +ms.date: 10/23/2023 uid: signalr/configuration --- @@ -325,6 +325,61 @@ var connection = new signalR.HubConnectionBuilder() --- +### Configure stateful reconnect options + +Stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. + +Stateful reconnect achieves this by: + +* Temporarily buffering data on the server and client. +* Acknowledging messages received (ACK-ing) by both the server and client. +* Recognizing when a connection is returning and replaying messages that may have been sent while the connection was down. + +To opt-in to stateful reconnect for a JavaScript or Typescript client: + +* Update the JavaScript or TypeScript client code to enable the `withStatefulReconnect` option: + + ```JavaScript + const builder = new signalR.HubConnectionBuilder() + .withUrl("/hubname") + .withStatefulReconnect({ bufferSize: 1000 }); // Optional, defaults to 100,000 + const connection = builder.build(); + ``` + + The `bufferSize` option is optional with a default of 100,000 bytes. + +* Update the server hub endpoint configuration to enable the `AllowStatefulReconnects` option: + + ```csharp + app.MapHub("/hubName", options => + { + options.AllowStatefulReconnects = true; + }); + ``` + +To opt-in to stateful reconnect for a .NET client: + +* Update the .NET client code to enable the `WithStatefulReconnect` option: + + ```csharp + var builder = new HubConnectionBuilder() + .WithUrl("") + .WithStatefulReconnect(); + builder.Services.Configure(o => o.StatefulReconnectBufferSize = 1000); + var hubConnection = builder.Build(); + ``` + + The `StatefulReconnectBufferSize` option is optional with a default of 100,000 bytes. + +* Update the server hub endpoint configuration to enable the `AllowStatefulReconnects` option: + + ```csharp + app.MapHub("/hubName", options => + { + options.AllowStatefulReconnects = true; + }); + ``` + ### Configure additional options Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript) method on `HubConnectionBuilder` or on the various configuration APIs on the `HttpHubConnectionBuilder` in the Java client: @@ -346,6 +401,7 @@ Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript) | `WebSocketConfiguration` | `null` | A delegate that can be used to configure additional WebSocket options. Receives an instance of that can be used to configure the options. | | `ApplicationMaxBufferSize` | 1 MB | The maximum number of bytes received from the server that the client buffers before applying backpressure. Increasing this value allows the client to receive larger messages faster without applying backpressure, but can increase memory consumption. | | `TransportMaxBufferSize` | 1 MB | The maximum number of bytes sent by the user application that the client buffers before observing backpressure. Increasing this value allows the client to buffer larger messages faster without awaiting backpressure, but can increase memory consumption. | +| `WithStatefulReconnect` | 100,000 | Enables stateful reconnect with a default | # [JavaScript](#tab/javascript) From 2a02f2b32c6ebe93c79932173bb2b05bd95b1a8b Mon Sep 17 00:00:00 2001 From: wadepickett Date: Tue, 24 Oct 2023 16:54:42 -0700 Subject: [PATCH 02/11] Removed draft entry under Configure additional --- aspnetcore/signalr/configuration.md | 1 - 1 file changed, 1 deletion(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index 64fc90b3091f..3e9886e0dbd6 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -401,7 +401,6 @@ Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript) | `WebSocketConfiguration` | `null` | A delegate that can be used to configure additional WebSocket options. Receives an instance of that can be used to configure the options. | | `ApplicationMaxBufferSize` | 1 MB | The maximum number of bytes received from the server that the client buffers before applying backpressure. Increasing this value allows the client to receive larger messages faster without applying backpressure, but can increase memory consumption. | | `TransportMaxBufferSize` | 1 MB | The maximum number of bytes sent by the user application that the client buffers before observing backpressure. Increasing this value allows the client to buffer larger messages faster without awaiting backpressure, but can increase memory consumption. | -| `WithStatefulReconnect` | 100,000 | Enables stateful reconnect with a default | # [JavaScript](#tab/javascript) From 08a53c71d95ac42ee247ad43425c28b1c7a1088b Mon Sep 17 00:00:00 2001 From: wadepickett Date: Tue, 24 Oct 2023 17:24:05 -0700 Subject: [PATCH 03/11] Changed section title --- aspnetcore/signalr/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index 3e9886e0dbd6..8f2d757cd54e 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -325,7 +325,7 @@ var connection = new signalR.HubConnectionBuilder() --- -### Configure stateful reconnect options +### Configure stateful reconnect Stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. From 9f8148bad76e715ddebc1ba5e131c4fd1668cf88 Mon Sep 17 00:00:00 2001 From: wadepickett Date: Wed, 25 Oct 2023 10:23:08 -0700 Subject: [PATCH 04/11] Indicated available in 8.0 or later --- aspnetcore/signalr/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index 8f2d757cd54e..435c7da2e7a5 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -327,7 +327,7 @@ var connection = new signalR.HubConnectionBuilder() ### Configure stateful reconnect -Stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. +Stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. Signalr stateful reconnect is available in ASP.NET Core 8.0 and later. Stateful reconnect achieves this by: From 7af6d5c87d66484405d25d6f6af1a03ca3b42d5f Mon Sep 17 00:00:00 2001 From: wadepickett Date: Wed, 25 Oct 2023 13:48:36 -0700 Subject: [PATCH 05/11] Typo correction --- aspnetcore/signalr/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index 435c7da2e7a5..54d5cbafc116 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -327,7 +327,7 @@ var connection = new signalR.HubConnectionBuilder() ### Configure stateful reconnect -Stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. Signalr stateful reconnect is available in ASP.NET Core 8.0 and later. +Stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. Stateful reconnect is available in ASP.NET Core 8.0 and later. Stateful reconnect achieves this by: From d198d6d68ea0b762edad3d71625fd265dbfb0bbb Mon Sep 17 00:00:00 2001 From: wadepickett Date: Thu, 26 Oct 2023 12:33:43 -0700 Subject: [PATCH 06/11] Moved server opt-in to top of examples per review --- aspnetcore/release-notes/aspnetcore-8.0.md | 29 ++++++++-------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/aspnetcore/release-notes/aspnetcore-8.0.md b/aspnetcore/release-notes/aspnetcore-8.0.md index ca57565efc33..0da7696f66ea 100644 --- a/aspnetcore/release-notes/aspnetcore-8.0.md +++ b/aspnetcore/release-notes/aspnetcore-8.0.md @@ -387,6 +387,17 @@ Stateful reconnect achieves this by: * Acknowledging messages received (ACK-ing) by both the server and client. * Recognizing when a connection is returning and replaying messages that may have been sent while the connection was down. +Opt-in to stateful reconnect at both the server hub enpoint and the client: + +* Update the server hub endpoint configuration to enable the `AllowStatefulReconnects` option: + + ```csharp + app.MapHub("/hubName", options => + { + options.AllowStatefulReconnects = true; + }); + ``` + To opt-in to stateful reconnect for a JavaScript or Typescript client: * Update the JavaScript or TypeScript client code to enable the `withStatefulReconnect` option: @@ -398,15 +409,6 @@ To opt-in to stateful reconnect for a JavaScript or Typescript client: const connection = builder.build(); ``` -* Update the server hub endpoint configuration to enable the `AllowStatefulReconnects` option: - - ```csharp - app.MapHub("/hubName", options => - { - options.AllowStatefulReconnects = true; - }); - ``` - To opt-in to stateful reconnect for a .NET client: * Update the .NET client code to enable the `UseStatefulReconnect` option: @@ -419,15 +421,6 @@ To opt-in to stateful reconnect for a .NET client: var hubConnection = builder.Build(); ``` -* Update the server hub endpoint configuration to enable the `AllowStatefulReconnects` option: - - ```csharp - app.MapHub("/hubName", options => - { - options.AllowStatefulReconnects = true; - }); - ``` - ## Minimal APIs This section describes new features for minimal APIs. See also [the section on native AOT](#native-aot) for more information relevant to minimal APIs. From 4f0587c4b16e39a87ca653548d53bc8d8046d45b Mon Sep 17 00:00:00 2001 From: Wade Pickett Date: Thu, 26 Oct 2023 12:57:16 -0700 Subject: [PATCH 07/11] Update aspnetcore-8.0.md Removed repeated statements, cleaned up. --- aspnetcore/release-notes/aspnetcore-8.0.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/aspnetcore/release-notes/aspnetcore-8.0.md b/aspnetcore/release-notes/aspnetcore-8.0.md index 0da7696f66ea..11eb88900eb8 100644 --- a/aspnetcore/release-notes/aspnetcore-8.0.md +++ b/aspnetcore/release-notes/aspnetcore-8.0.md @@ -385,7 +385,7 @@ Stateful reconnect achieves this by: * Temporarily buffering data on the server and client. * Acknowledging messages received (ACK-ing) by both the server and client. -* Recognizing when a connection is returning and replaying messages that may have been sent while the connection was down. +* Recognizing when a connection is returning and replaying messages that might have been sent while the connection was down. Opt-in to stateful reconnect at both the server hub enpoint and the client: @@ -398,9 +398,7 @@ Opt-in to stateful reconnect at both the server hub enpoint and the client: }); ``` -To opt-in to stateful reconnect for a JavaScript or Typescript client: - -* Update the JavaScript or TypeScript client code to enable the `withStatefulReconnect` option: +* Update JavaScript or TypeScript client code to enable the `withStatefulReconnect` option: ```JavaScript const builder = new signalR.HubConnectionBuilder() @@ -409,9 +407,7 @@ To opt-in to stateful reconnect for a JavaScript or Typescript client: const connection = builder.build(); ``` -To opt-in to stateful reconnect for a .NET client: - -* Update the .NET client code to enable the `UseStatefulReconnect` option: +* Update .NET client code to enable the `WithStatefulReconnect` option: ```csharp var builder = new HubConnectionBuilder() From 49058363ca14ac47d95b64193fe8a6e8633d9da7 Mon Sep 17 00:00:00 2001 From: Wade Pickett Date: Thu, 26 Oct 2023 13:01:13 -0700 Subject: [PATCH 08/11] Update configuration.md Moved server example to top, cleaned up. --- aspnetcore/signalr/configuration.md | 41 +++++++++-------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index 54d5cbafc116..136854c885ef 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -327,26 +327,15 @@ var connection = new signalR.HubConnectionBuilder() ### Configure stateful reconnect -Stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. Stateful reconnect is available in ASP.NET Core 8.0 and later. +SignalR stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. Stateful reconnect achieves this by: * Temporarily buffering data on the server and client. * Acknowledging messages received (ACK-ing) by both the server and client. -* Recognizing when a connection is returning and replaying messages that may have been sent while the connection was down. +* Recognizing when a connection is returning and replaying messages that might have been sent while the connection was down. -To opt-in to stateful reconnect for a JavaScript or Typescript client: - -* Update the JavaScript or TypeScript client code to enable the `withStatefulReconnect` option: - - ```JavaScript - const builder = new signalR.HubConnectionBuilder() - .withUrl("/hubname") - .withStatefulReconnect({ bufferSize: 1000 }); // Optional, defaults to 100,000 - const connection = builder.build(); - ``` - - The `bufferSize` option is optional with a default of 100,000 bytes. +Opt-in to stateful reconnect at both the server hub enpoint and the client: * Update the server hub endpoint configuration to enable the `AllowStatefulReconnects` option: @@ -357,9 +346,16 @@ To opt-in to stateful reconnect for a JavaScript or Typescript client: }); ``` -To opt-in to stateful reconnect for a .NET client: +* Update JavaScript or TypeScript client code to enable the `withStatefulReconnect` option: + + ```JavaScript + const builder = new signalR.HubConnectionBuilder() + .withUrl("/hubname") + .withStatefulReconnect({ bufferSize: 1000 }); // Optional, defaults to 100,000 + const connection = builder.build(); + ``` -* Update the .NET client code to enable the `WithStatefulReconnect` option: +* Update .NET client code to enable the `WithStatefulReconnect` option: ```csharp var builder = new HubConnectionBuilder() @@ -369,17 +365,6 @@ To opt-in to stateful reconnect for a .NET client: var hubConnection = builder.Build(); ``` - The `StatefulReconnectBufferSize` option is optional with a default of 100,000 bytes. - -* Update the server hub endpoint configuration to enable the `AllowStatefulReconnects` option: - - ```csharp - app.MapHub("/hubName", options => - { - options.AllowStatefulReconnects = true; - }); - ``` - ### Configure additional options Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript) method on `HubConnectionBuilder` or on the various configuration APIs on the `HttpHubConnectionBuilder` in the Java client: @@ -483,4 +468,4 @@ HubConnection hubConnection = HubConnectionBuilder.create("https://example.com/c [!INCLUDE[](~/signalr/configuration/includes/configuration6.md)] -[!INCLUDE[](~/signalr/configuration/includes/configuration7.md)] \ No newline at end of file +[!INCLUDE[](~/signalr/configuration/includes/configuration7.md)] From 772a0d5488f0b6f4e83df6c6443a2224736e6257 Mon Sep 17 00:00:00 2001 From: Wade Pickett Date: Thu, 26 Oct 2023 13:01:51 -0700 Subject: [PATCH 09/11] Update configuration.md Updated ms.date --- aspnetcore/signalr/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index 136854c885ef..bd88cd1d120d 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -5,7 +5,7 @@ description: Learn how to configure ASP.NET Core SignalR apps. monikerRange: '>= aspnetcore-2.1' ms.author: bradyg ms.custom: mvc -ms.date: 10/23/2023 +ms.date: 10/26/2023 uid: signalr/configuration --- From 33348324a27c91f3ec0dfcabae1a163c9dea1e21 Mon Sep 17 00:00:00 2001 From: Wade Pickett Date: Thu, 26 Oct 2023 13:21:25 -0700 Subject: [PATCH 10/11] Update aspnetcore-8.0.md --- aspnetcore/release-notes/aspnetcore-8.0.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aspnetcore/release-notes/aspnetcore-8.0.md b/aspnetcore/release-notes/aspnetcore-8.0.md index 11eb88900eb8..c67b528e57c9 100644 --- a/aspnetcore/release-notes/aspnetcore-8.0.md +++ b/aspnetcore/release-notes/aspnetcore-8.0.md @@ -406,7 +406,9 @@ Opt-in to stateful reconnect at both the server hub enpoint and the client: .withStatefulReconnect({ bufferSize: 1000 }); // Optional, defaults to 100,000 const connection = builder.build(); ``` - + + The `bufferSize` option is optional with a default of 100,000 bytes. + * Update .NET client code to enable the `WithStatefulReconnect` option: ```csharp @@ -417,6 +419,8 @@ Opt-in to stateful reconnect at both the server hub enpoint and the client: var hubConnection = builder.Build(); ``` + The `StatefulReconnectBufferSize` option is optional with a default of 100,000 bytes. + ## Minimal APIs This section describes new features for minimal APIs. See also [the section on native AOT](#native-aot) for more information relevant to minimal APIs. From 40ed6ad2a14edebae2ccce6574b69e46d8472bad Mon Sep 17 00:00:00 2001 From: Wade Pickett Date: Thu, 26 Oct 2023 13:23:09 -0700 Subject: [PATCH 11/11] Update configuration.md cleaned up --- aspnetcore/signalr/configuration.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aspnetcore/signalr/configuration.md b/aspnetcore/signalr/configuration.md index bd88cd1d120d..6bcb38c927d1 100644 --- a/aspnetcore/signalr/configuration.md +++ b/aspnetcore/signalr/configuration.md @@ -327,7 +327,7 @@ var connection = new signalR.HubConnectionBuilder() ### Configure stateful reconnect -SignalR stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. +SignalR stateful reconnect reduces the perceived downtime of clients that have a temporary disconnect in their network connection, such as when switching network connections or a short temporary loss in access. Stateful reconnect is available in ASP.NET Core 8.0 and later. Stateful reconnect achieves this by: @@ -354,7 +354,9 @@ Opt-in to stateful reconnect at both the server hub enpoint and the client: .withStatefulReconnect({ bufferSize: 1000 }); // Optional, defaults to 100,000 const connection = builder.build(); ``` - + + The `bufferSize` option is optional with a default of 100,000 bytes. + * Update .NET client code to enable the `WithStatefulReconnect` option: ```csharp @@ -365,6 +367,8 @@ Opt-in to stateful reconnect at both the server hub enpoint and the client: var hubConnection = builder.Build(); ``` + The `StatefulReconnectBufferSize` option is optional with a default of 100,000 bytes. + ### Configure additional options Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript) method on `HubConnectionBuilder` or on the various configuration APIs on the `HttpHubConnectionBuilder` in the Java client: