SignalR Health Checks do not work with Azure SignalR
See original GitHub issueWhat happened:
We tried implementing SignalR health checks for our Azure SignalR resource(s), but no matter inputs we tried with the Xabaril .AddSignalRHub(...) method, we always got a 403 Forbidden response, an exception, and an unhealthy health check result.
What you expected to happen: We expect the library to provide some way to verify a healthy Azure SignalR endpoint/hub/resource through either providing the Access Key or proper bearer token as part of the hub connection.
Things that do not appear to work:
- Using a direct URL after attaching the signalR hub as an endpoint:
app.UseEndpoints(endpoints => endpoints.MapHub<NotificationHub>("/Notification"));
services.AddHealthChecks()
.AddSignalRHub("https://myapp-signalr.service.signalr.net/notification", "signalRTest1");
- Using a direct URL after attaching the signalR hub as an endpoint:
ServiceProvider sp = services.BuildServiceProvider();
var tokenManager = sp.GetService<ITokenManager>();
AuthenticatedCredentials credentials = tokenManager.RetrieveCredentials(myAppAuthSettings)
.GetAwaiter()
.GetResult();
HubConnection connection = new HubConnectionBuilder()
.WithUrl("https://myapp-signalr.service.signalr.net/notification", options =>
{
options.AccessTokenProvider = () => Task.FromResult(credentials.AccessToken);
})
.Build();
services.AddHealthChecks()
.AddSignalRHub("https://myapp-signalr.service.signalr.net/notification", "signalrTest2");
Remaining questions:
- Is Azure SignalR supported by Xabaril AspNetCore.Diagnostics.HealthChecks?
- If I have my Azure SignalR Connection string, is there some way I can use that or the pieces therein to activate the health check without resulting in a 403? (e.g. “Endpoint=https://myapp-signalr.service.signalr.net;AccessKey=2xo7Pgaj6EVGkF8TbMQCOAeZ4AwH2r8/aFQ9+7r87B2=;Version=1.0;”)
- .NET Core version: 3.1
- Microsoft.Extensions.Diagnostics.HealthChecks: 3.1.5
- AspNetCore.Healthchecks.SignalR version: 3.1.1
- Microsoft.Azure.SignalR: 1.4.3
Additional Question/Consideration:
@ChrisProlls logged issue #524 that implies that a uri of https://mydomain.com/hub would allow one to create a signalR health check, but does such a method not work for something like Azure SignalR where an access key or bearer token authentication is required?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:8 (3 by maintainers)
Top Related StackOverflow Question
In case this helps anyone - instead of checking the Azure SignalR hubs (I am already checking the local ones in my app) I went with the standard health api on my endpoint using the connectionString:
Hi @atwoodr
Azure SignalR is not tested , let me some days to check this issue and I come back with more info! I try to solve the issue you mentioned with Azure SignalR and api key, bearer tokens, probably we need a new extension method for Azure SignalR