Skip to content

Commit c284046

Browse files
authored
[SignalR extensions] Release v1.12.0 (Azure#39668)
* Release v1.11.2 * [SignalR extensions] Add Retry Options * [SignalR extensions] Fix the bug that secondary connection string not working * Add HTTP client timeout setting * Prepare for the release v1.12.0
1 parent c0a7a8d commit c284046

File tree

12 files changed

+229
-19
lines changed

12 files changed

+229
-19
lines changed

eng/Packages.Data.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@
143143
<PackageReference Update="Grpc.Tools" Version="2.51.0" PrivateAssets="all" />
144144
<PackageReference Update="MessagePack" Version="1.9.11" />
145145
<PackageReference Update="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="1.1.5" />
146-
<PackageReference Update="Microsoft.Azure.SignalR" Version="1.21.6" />
147-
<PackageReference Update="Microsoft.Azure.SignalR.Management" Version="1.21.6" />
148-
<PackageReference Update="Microsoft.Azure.SignalR.Protocols" Version="1.21.6" />
146+
<PackageReference Update="Microsoft.Azure.SignalR" Version="1.22.0" />
147+
<PackageReference Update="Microsoft.Azure.SignalR.Management" Version="1.22.0" />
148+
<PackageReference Update="Microsoft.Azure.SignalR.Protocols" Version="1.22.0" />
149149
<PackageReference Update="Microsoft.Azure.SignalR.Serverless.Protocols" Version="1.9.0" />
150150
<PackageReference Update="Microsoft.Azure.WebJobs" Version="3.0.37" />
151151
<PackageReference Update="Microsoft.Azure.WebJobs.Sources" Version="3.0.37" PrivateAssets="All"/>

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Release History
22

3-
## 1.12.0-beta.1 (Unreleased)
4-
3+
## 1.12.0 (2023-11-07)
54
### Features Added
6-
7-
### Breaking Changes
5+
* Added `RetryOptions` to `SignalROptions` to configure retry policy for SignalR Service REST API calls. For more infomation about cutomize retry options, see samples.
6+
* Added `HttpClientTimeout` to `SignalROptions` to configure HTTP client timeout for SignalR Service REST API calls. The default value is 100 seconds. User can also set "AzureSignalRHttpClientTimeout" in the app settings to override the default value.
87

98
### Bugs Fixed
9+
* Fixed the issue when using customized server endpoint with Azure AD credential.
10+
* Fixed the issue that SignalR trigger is not working with secondary connection string.
1011

1112
### Other Changes
13+
* Upgraded `Microsoft.Azure.SignalR`, `Microsoft.Azure.SignalR.Management`, `Microsoft.Azure.SignalR.Protocols` from 1.21.6 to 1.22.0
1214

1315
## 1.11.2 (2023-09-12)
1416

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/api/Microsoft.Azure.WebJobs.Extensions.SignalRService.netstandard2.0.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ public SignalRNegotiationAttribute() { }
236236
public partial class SignalROptions : Microsoft.Azure.WebJobs.Hosting.IOptionsFormatter
237237
{
238238
public SignalROptions() { }
239-
public Azure.Core.Serialization.ObjectSerializer JsonObjectSerializer { get { throw null; } set { } }
240-
public Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol MessagePackHubProtocol { get { throw null; } set { } }
239+
public System.TimeSpan? HttpClientTimeout { get { throw null; } set { } }
240+
public Azure.Core.Serialization.ObjectSerializer? JsonObjectSerializer { get { throw null; } set { } }
241+
public Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol? MessagePackHubProtocol { get { throw null; } set { } }
242+
public Microsoft.Azure.SignalR.Management.ServiceManagerRetryOptions? RetryOptions { get { throw null; } set { } }
241243
public System.Collections.Generic.IList<Microsoft.Azure.SignalR.ServiceEndpoint> ServiceEndpoints { get { throw null; } }
242244
public Microsoft.Azure.SignalR.Management.ServiceTransportType ServiceTransportType { get { throw null; } set { } }
243245
string Microsoft.Azure.WebJobs.Hosting.IOptionsFormatter.Format() { throw null; }

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/samples/Sample04_MessagePack.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# MessagePack Hub Protocol
2+
23
[MessagePack hub protocol](https://learn.microsoft.com/aspnet/core/signalr/messagepackhubprotocol?view=aspnetcore-7.0) is a built-in SignalR hub protocol which is faster and compacter than JSON hub protocol. You can enable MessagePack hub protocol in SignalR extensions to support MessagePack clients. MessagePack hub protocol works for both persistent mode and transient mode.
34

45
> For transient mode, by default the service side converts JSON payload to MessagePack payload and it's the legacy way to support MessagePack. However, we recommend you to add a MessagePack hub protocol explicitly as the behavior of legacy way is not exactly the same as self-hosted SignalR.
56
67
You have two options to enable MessagePack hub protocol.
8+
79
1. Update application settings
810
2. Update .NET code
911

10-
# Option 1: Update application settings
12+
## Option 1: Update application settings
1113

1214
For your Azure functions app, add the following app setting to your Azure functions:
1315
```
@@ -24,7 +26,7 @@ If you run the app locally, you should add the setting to your `local.settings.j
2426

2527
```
2628

27-
# Option 2: Update .NET code
29+
## Option 2: Update .NET code
2830

2931
Use the following code to enable MessagePack hub protocol:
3032
```C# Snippet:MessagePackCustomization
@@ -35,6 +37,4 @@ public class MessagePackStartup : FunctionsStartup
3537
builder.Services.Configure<SignalROptions>(o => o.MessagePackHubProtocol = new MessagePackHubProtocol());
3638
}
3739
}
38-
```
39-
40-
40+
```
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# HTTP Retry
2+
3+
For the **transient** mode, this SDK provides the capability to automatically resend requests when transient errors occur, as long as the requests are idempotent.
4+
5+
## Which kinds of requests are tried
6+
7+
In particular, the following types of requests are retried:
8+
9+
* For message requests that send messages to SignalR clients, the SDK retries the request if the HTTP response status code is greater than 500. Note that when the HTTP response code is equal to 500, it may indicate a timeout on the service side, and retrying the request could result in duplicate messages.
10+
11+
* For other types of requests, such as adding a connection to a group, the SDK retries the request under the following conditions:
12+
1. The HTTP response status code is in the 5xx range, or the request timed out with a status code of 408 (Request Timeout).
13+
2. The request timed out.
14+
15+
Please note that the SDK can only retry idempotent requests, which are requests that have no additional effect if they are repeated. If your requests are not idempotent, you may need to handle retries manually.
16+
17+
## Retry options
18+
19+
### Retry modes
20+
The SDK provides two retry modes, `Exponential` and `Fixed`. The default retry mode is `FixedRetryPolicy`, which retries requests with a fixed interval. The`ExponentialRetryPolicy` retries requests with an exponential backoff.
21+
22+
### Max retry counts
23+
The maximum number of retry attempts before giving up. The default value is 3.
24+
25+
### Delay timespan
26+
The delay between retry attempts for a fixed approach or the delay on which to base calculations for a backoff-based approach. The default value is 0.8 seconds.
27+
28+
### Max delay timespan
29+
The maximum permissible delay between retry attempts. The default value is 1 minute.
30+
31+
32+
## How to enable retry
33+
34+
You have two options to enable retry.
35+
36+
1. Update application settings
37+
2. Update .NET code
38+
39+
### Option 1: Update application settings
40+
41+
For your Azure functions app, add the following app settings to your Azure functions:
42+
43+
The settings set the mode to `Fixed`, max retries to 3 and the delay timespan to 2 seconds.
44+
```
45+
AzureSignalRRetry__MaxRetries = 2
46+
AzureSignalRRetry__Delay = 00:00:02
47+
AzureSignalRRetry__Mode = Fixed
48+
```
49+
50+
The settings set the mode to `Exponential`, max retries to 3 and the initial delay timespan to 1 seconds.
51+
52+
```
53+
AzureSignalRRetry__MaxRetries = 3
54+
AzureSignalRRetry__Delay = 00:00:01
55+
AzureSignalRRetry__Mode = Exponential
56+
```
57+
58+
59+
If you run the app locally, you should add the setting to your `local.settings.json` file and replace the `__` with `:` in the key name.
60+
61+
```json
62+
{
63+
"Values": {
64+
"AzureSignalRRetry:MaxRetries": "3",
65+
}
66+
}
67+
68+
```
69+
70+
## Option 2: Update .NET code
71+
72+
```C# Snippet:RetryCustomization
73+
public class RetryStartup : FunctionsStartup
74+
{
75+
public override void Configure(IFunctionsHostBuilder builder)
76+
{
77+
builder.Services.Configure<SignalROptions>(o => o.RetryOptions = new ServiceManagerRetryOptions
78+
{
79+
Mode = ServiceManagerRetryMode.Exponential,
80+
MaxDelay = TimeSpan.FromSeconds(30),
81+
MaxRetries = 5,
82+
Delay = TimeSpan.FromSeconds(1),
83+
});
84+
}
85+
}
86+
```

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/src/Config/OptionsSetup.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public OptionsSetup(IConfiguration configuration, AzureComponentFactory azureCom
2929
options.ServiceEndpoints = optionsFromCode.ServiceEndpoints?.ToArray();
3030
options.ServiceTransportType = optionsFromCode.ServiceTransportType;
3131
options.UseJsonObjectSerializer(optionsFromCode.JsonObjectSerializer);
32+
options.RetryOptions = optionsFromCode.RetryOptions;
33+
if (optionsFromCode.HttpClientTimeout.HasValue)
34+
{
35+
options.HttpClientTimeout = optionsFromCode.HttpClientTimeout.Value;
36+
}
3237

3338
// Apply options from configuration
3439
if (_configuration.TryGetJsonObjectSerializer(out var serializer))
@@ -61,6 +66,18 @@ public OptionsSetup(IConfiguration configuration, AzureComponentFactory azureCom
6166
}
6267
//make connection more stable
6368
options.ConnectionCount = 3;
69+
70+
var retryOptions = _configuration.GetSection(Constants.AzureSignalRRetry).Get<ServiceManagerRetryOptions>();
71+
if (retryOptions != null)
72+
{
73+
options.RetryOptions = retryOptions;
74+
}
75+
76+
var httpClientTimeout = _configuration.GetSection(Constants.AzureSignalRHttpClientTimeout).Get<TimeSpan>();
77+
if (httpClientTimeout != default)
78+
{
79+
options.HttpClientTimeout = httpClientTimeout;
80+
}
6481
};
6582
}
6683

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/src/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ internal static class Constants
1111
public static string AzureSignalRNewtonsoftCamelCase = $"{AzureSignalRHubProtocol}:NewtonsoftJson:CamelCase";
1212
public static string AzureSignalRMessagePackHubProtocolEnabled = $"{AzureSignalRHubProtocol}:MessagePack:Enabled";
1313
public const string ServiceTransportTypeName = "AzureSignalRServiceTransportType";
14+
public const string AzureSignalRRetry = "AzureSignalRRetry";
15+
public const string AzureSignalRHttpClientTimeout = "AzureSignalRHttpClientTimeout";
1416
public const string AsrsHeaderPrefix = "X-ASRS-";
1517
public const string AsrsConnectionIdHeader = AsrsHeaderPrefix + "Connection-Id";
1618
public const string AsrsUserClaims = AsrsHeaderPrefix + "User-Claims";

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/src/Microsoft.Azure.WebJobs.Extensions.SignalRService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
55
<PackageId>Microsoft.Azure.WebJobs.Extensions.SignalRService</PackageId>
6-
<Version>1.12.0-beta.1</Version>
6+
<Version>1.12.0</Version>
77
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
88
<ApiCompatVersion>1.11.2</ApiCompatVersion>
99
<SignAssembly>true</SignAssembly>

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/src/SignalROptions.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
using Newtonsoft.Json;
1313
using Newtonsoft.Json.Linq;
1414

15+
#nullable enable
16+
1517
namespace Microsoft.Azure.WebJobs.Extensions.SignalRService
1618
{
1719
/// <summary>
@@ -22,7 +24,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.SignalRService
2224
/// </remarks>
2325
public class SignalROptions : IOptionsFormatter
2426
{
25-
private IHubProtocol _messagePackHubProtocol;
27+
private IHubProtocol? _messagePackHubProtocol;
2628

2729
/// <summary>
2830
/// Gets the list of SignalR service.
@@ -37,12 +39,22 @@ public class SignalROptions : IOptionsFormatter
3739
/// <summary>
3840
/// Gets or sets the JSON object serializer.
3941
/// </summary>
40-
public ObjectSerializer JsonObjectSerializer { get; set; }
42+
public ObjectSerializer? JsonObjectSerializer { get; set; }
43+
44+
/// <summary>
45+
/// Gets or sets the retry options.
46+
/// </summary>
47+
public ServiceManagerRetryOptions? RetryOptions { get; set; }
48+
49+
/// <summary>
50+
/// Gets or sets the timespan for HttpClient timeout.
51+
/// </summary>
52+
public TimeSpan? HttpClientTimeout { get; set; }
4153

4254
/// <summary>
4355
/// Gets or sets the MessagePack hub <see cref="IHubProtocol"/>. Defaults to null and MessagePack hub protocol is not used.
4456
/// </summary>
45-
public IHubProtocol MessagePackHubProtocol
57+
public IHubProtocol? MessagePackHubProtocol
4658
{
4759
get => _messagePackHubProtocol; set
4860
{

sdk/signalr/Microsoft.Azure.WebJobs.Extensions.SignalRService/src/TriggerBindings/Utils/SignalRTriggerUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static IReadOnlyList<string> GetSignatureList(string signatures)
4949
return default;
5050
}
5151

52-
return signatures.Split(HeaderSeparator, StringSplitOptions.RemoveEmptyEntries);
52+
return signatures.Split(HeaderSeparator, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
5353
}
5454

5555
public static IDictionary<string, string> GetHeaderDictionary(HttpRequestHeaders headers)

0 commit comments

Comments
 (0)