'Azure SignalR Service Connection is not active

I updated our signalr packages from 2.4.0 and added RunAzureSignalR instead of RunSignalR. Added this code in de Startup.cs

app.Map("/signalr", map =>
{
    var hubConfiguration = new HubConfiguration
    {
        EnableDetailedErrors = true
    };

    map.RunAzureSignalR(typeof(Startup).FullName, hubConfiguration, options =>
    {
        options.ConnectionString = AppApiSettings.SignalRServiceConnectionString;
    });
});

But when I try to send a message to the hub I get an exception The connection is not active, data cannot be sent to the service.. Can't find any reason this would happen or why the service would not run.

When I use RunSignalR (self hosted) everything runs great.

Any help would be greatly appreciated.



Solution 1:[1]

I've recently had the same issue whereby the negotiation worked with map.RunSignalR(...) but not map.RunAzureSignalR(...) and tried the accepted answer here without resolution. For anyone still experiencing this issue having tried the accepted answer like myself, I found the below to work for a .NET Framework 4.6.1 project.

Navigating to the negotiation link (e.g. .../signalr/negotiate?clientProtocol=2.1&connectionData=...&callback=jQuery...&_=...) in the browser would give a

HTTP 500: Azure SignalR Service is not connected yet, please try again later

Having enabled the exception debugging suggestions from @Youp Hulsebos and the SignalR GitHub (source), I was able to find the following exceptions being thrown from the SignalR registration call in Startup.Configure(...):

Microsoft.Azure.SignalR.Common.ServiceConnectionNotActiveException: 'The connection is not active, data cannot be sent to the service.'

LoaderException - Method 'get_Features' in type 'Microsoft.AspNetCore.Http.Connections.Client.HttpConnection' from assembly 'Microsoft.AspNetCore.Http.Connections.Client, Version=1.0.0.0, Culture=neutral' does not have an implementation.":"Microsoft.AspNetCore.Http.Connections.Client.HttpConnection"

Having found the second of these exceptions and applying some Google-fu, I found this GitHub issue discussing the LoaderException from Microsoft.Azure.SignalR.WebSocketConnectionContext discussing this as the result of upgrading Microsoft.AspNetCore.Http.Connections.Client from 5.0.12.0 to 6.0.0.0.

Having tried downgrading the package to 5.0.12.0, I still encountered the same issue. Having checked the linked issue ([dotnet/aspnetcore#38699]), I downgraded the following packages to 5.0.11.0 and this resolved the issue:

  • Microsoft.AspNetCore.Connections.Abstractions
  • Microsoft.AspNetCore.Http.Connections.Client
  • Microsoft.AspNetCore.Http.Connections.Common
  • Microsoft.AspNetCore.Http.Features

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1