Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hub name used in Azure SignalR Service is the name of the hub class and not the hub name path #1769

Open
Vinnycout opened this issue Mar 3, 2023 · 1 comment

Comments

@Vinnycout
Copy link

Vinnycout commented Mar 3, 2023

Describe the bug

Hub name used in Azure SignalR Service is the name of the hub class in lowercase and not the hub name it was mapped with

To Reproduce

I have attached the sample to the bug report.

The system only works if the path provided for the hub is the name of the class implementing the hub !!!

if your signalR hub class if called MySignalRHub, the name to provide for the hub name path has to be "/mysignalrhub"

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHub<MySignalRHub>("/mysignalrhub");
        });

Exceptions (if any)

Microsoft.AspNetCore.SignalR.HubException: 'Unable to complete handshake with the server due to an error: SignalR Service is now in 'Default' service mode.

SignalR Sample.zip

Further technical details

  • Your Azure SignalR SDK version => Latest (1.21.2)

  • Your Server ASPNETCORE version or Assembly version of Microsoft.AspNetCore.SignalR Latest (7.0.3)

  • Your SignalR Client SDK version Latest (1.21.2)

    <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.3" />
    <PackageReference Include="Microsoft.Azure.SignalR" Version="1.21.2" />
    
@vicancy
Copy link
Member

vicancy commented Mar 10, 2023

/mysignalrhub is your web server path to serve your hub requests, it does not need to be the name of the class implementing the hub.

Your sample code fails because it connects to Azure SignalR directly and it reuses the variable SignalRHubName that your local path uses as the hub name.

In your sample code, there is no need for your web page Counter.razor to be aware of Azure SignalR endpoints, your web page still new HubConnectionBuilder().WithUrl("your web server url"), under the hood, your app server side, when receives the client negotiate requests, would redirect the client to connect with Azure SignalR. For the detailed workflow, please see https://learn.microsoft.com/en-us/azure/azure-signalr/signalr-concept-internals#client-connections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants