SignalR Health Checks do not work with Azure SignalR

See original GitHub issue

What 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:

  1. Is Azure SignalR supported by Xabaril AspNetCore.Diagnostics.HealthChecks?
  2. 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:open
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
dvirycommented, Dec 25, 2021

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:

        services.AddHealthChecks()
                .AddUrlGroup(
                    new Uri(
                        new Uri(new ServiceEndpoint(hubOptions.ConnectionString).Endpoint), 
                        "/api/v1/health"),
                    name: "SignalR Azure Hub",
                    failureStatus: HealthStatus.Degraded,
                    tags: new[] { "cloud", "azure" });
1reaction
unaizorrillacommented, Jun 23, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add Azure SignalR to health checks
How to add Azure SignalR to health checks ... Unhealthy Invalid URI: The URI scheme is not valid. My URI scheme: Endpoint=https://xxxx.service.
Read more >
Troubleshooting practice for Azure SignalR Service
First, you need to check from the Azure portal which ServiceMode is the Azure SignalR Service (also known as ASRS) configured to.
Read more >
AspNetCore.HealthChecks.SignalR 7.0.0
HealthChecks.SignalR is the health check package for SignalR.
Read more >
Replace Signal R with Azure Signal R #9976
The problem comes how to setup Signal R/Azure Signal R within an Azure function and even more so, in order to reuse existing...
Read more >
Azure SignalR binding spec
Detailed documentation on the Azure SignalR binding component. ... By default the Azure SignalR output binding will broadcast messages to all connected ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found