Skip to content

Commit 7e51478

Browse files
authored
Release 1.15.2
2 parents 74ec5cc + b929567 commit 7e51478

File tree

7 files changed

+60
-9
lines changed

7 files changed

+60
-9
lines changed

docs/emulator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Azure SignalR Local Emulator
22

3-
When developing serverless applications, we provide an Azure SignalR Local Emulator to make the local development and integration easier. Please note that the emulator works only for serverless scenarios, for *Default* mode that the Azure SignalR Service acts as a proxy, you can directly use self-host SignalR to do local development.
3+
When developing serverless applications, we provide an Azure SignalR Local Emulator to make the local development and integration easier. Please note that the emulator works only for serverless scenarios, for *Default* mode that the Azure SignalR Service acts as a proxy, you can directly use self-host SignalR to do local development. Please also note that emulator only works for *Transient* transport type (the default one) and doesn't work for *Persistent* transport type.
44

55
Features available
66
------------------

src/Microsoft.Azure.SignalR.Common/Utilities/RestClient.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ public async Task ThrowExceptionOnResponseFailureAsync(HttpResponseMessage respo
9696

9797
var detail = await response.Content.ReadAsStringAsync();
9898

99+
#if NET5_0_OR_GREATER
99100
var innerException = new HttpRequestException(
100-
$"Response status code does not indicate success: {(int)response.StatusCode} ({response.ReasonPhrase})"); ;
101-
101+
$"Response status code does not indicate success: {(int)response.StatusCode} ({response.ReasonPhrase})", null, response.StatusCode);
102+
#else
103+
var innerException = new HttpRequestException(
104+
$"Response status code does not indicate success: {(int)response.StatusCode} ({response.ReasonPhrase})");
105+
#endif
102106
throw response.StatusCode switch
103107
{
104108
HttpStatusCode.BadRequest => new AzureSignalRInvalidArgumentException(response.RequestMessage.RequestUri.ToString(), innerException, detail),

src/Microsoft.Azure.SignalR.Management/ServiceManagerImpl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ public async Task<IServiceHubContext> CreateHubContextAsync(string hubName, ILog
4343
public override Task<ServiceHubContext> CreateHubContextAsync(string hubName, CancellationToken cancellationToken)
4444
{
4545
var builder = new ServiceHubContextBuilder(_services);
46-
builder.ConfigureServices(services => services.Configure<ServiceManagerOptions>(o => o.ConnectionCount = 3));
4746
return builder.CreateAsync(hubName, cancellationToken);
4847
}
4948

5049
public override Task<ServiceHubContext<T>> CreateHubContextAsync<T>(string hubName, CancellationToken cancellation)
5150
{
5251
var builder = new ServiceHubContextBuilder(_services);
53-
builder.ConfigureServices(services => services.Configure<ServiceManagerOptions>(o => o.ConnectionCount = 3));
5452
return builder.CreateAsync<T>(hubName, cancellation);
5553
}
5654

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Net;
5+
using System.Net.Http;
6+
using System.Threading.Tasks;
7+
using Azure.Core.Serialization;
8+
using Microsoft.Azure.SignalR.Tests.Common;
9+
using Microsoft.Extensions.DependencyInjection;
10+
using Xunit;
11+
12+
namespace Microsoft.Azure.SignalR.Common.Tests.RestClients
13+
{
14+
public class RestClientFacts
15+
{
16+
#if NET5_0_OR_GREATER
17+
[Fact]
18+
public async Task TestHttpRequestExceptionWithStatusCodeSetAsync()
19+
{
20+
var httpClientFactory = new ServiceCollection()
21+
.AddHttpClient("").ConfigurePrimaryHttpMessageHandler(() => new TestRootHandler(HttpStatusCode.InsufficientStorage)).Services
22+
.BuildServiceProvider().GetRequiredService<IHttpClientFactory>();
23+
var client = new RestClient(httpClientFactory, new JsonObjectSerializer(), true);
24+
var exception = await Assert.ThrowsAsync<AzureSignalRRuntimeException>(() => client.SendAsync(new RestApiEndpoint("https://localhost.test.com", "token"), HttpMethod.Get, "", handleExpectedResponse: null));
25+
var httpRequestException = Assert.IsType<HttpRequestException>(exception.InnerException);
26+
Assert.Equal(HttpStatusCode.InsufficientStorage, httpRequestException.StatusCode);
27+
}
28+
#endif
29+
}
30+
}

test/Microsoft.Azure.SignalR.Management.Tests/ServiceManagerFacts.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,23 @@ public async Task TestCreateServiceHubContext()
192192
.ConfigureServices(services => services.AddSingleton<RestClientFactory>(new TestRestClientFactory(UserAgent, HttpStatusCode.OK)))
193193
.BuildServiceManager()
194194
.CreateHubContextAsync(HubName, default);
195-
Assert.Equal(3, (serviceHubContext as ServiceHubContextImpl).ServiceProvider.GetRequiredService<IOptions<ServiceManagerOptions>>().Value.ConnectionCount);
195+
Assert.Equal(1, (serviceHubContext as ServiceHubContextImpl).ServiceProvider.GetRequiredService<IOptions<ServiceManagerOptions>>().Value.ConnectionCount);
196+
}
197+
198+
[Fact]
199+
public async Task TestConnectionCountCustomizable()
200+
{
201+
using var serviceHubContext = await new ServiceManagerBuilder()
202+
.WithOptions(o =>
203+
{
204+
o.ConnectionString = _testConnectionString;
205+
o.ConnectionCount = 5;
206+
})
207+
// avoid waiting for health check result for long time
208+
.ConfigureServices(services => services.AddSingleton<RestClientFactory>(new TestRestClientFactory(UserAgent, HttpStatusCode.OK)))
209+
.BuildServiceManager()
210+
.CreateHubContextAsync(HubName, default);
211+
Assert.Equal(5, (serviceHubContext as ServiceHubContextImpl).ServiceProvider.GetRequiredService<IOptions<ServiceManagerOptions>>().Value.ConnectionCount);
196212
}
197213
}
198214
}

test/Microsoft.Azure.SignalR.Tests.Common/TestRootHandler.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ protected override void Dispose(bool disposing)
4040
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
4141
{
4242
//to avoid possible retry policy which dispose content, create new content each time
43-
var response = new HttpResponseMessage(_code);
43+
var response = new HttpResponseMessage(_code)
44+
{
45+
RequestMessage = request
46+
};
4447
if (_content != null)
4548
{
4649
response.Content = new ByteArrayContent(Encoding.UTF8.GetBytes(_content));

version.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>1.15.1</VersionPrefix>
3+
<VersionPrefix>1.15.2</VersionPrefix>
44
<VersionSuffix>preview1</VersionSuffix>
55
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
66
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
77
<BuildNumber Condition="'$(BuildNumber)' == ''">t000</BuildNumber>
88
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(FeatureBranchVersionSuffix)' != ''">$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-'))</VersionSuffix>
99
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
1010
</PropertyGroup>
11-
</Project>
11+
</Project>

0 commit comments

Comments
 (0)