Open Closed

Authentication issue with Blazor WASM SignalR in Commercial not in opensource #2962


User avatar
0
Sturla created

I created this ticket in GitHub where I was able to get SignalR to work in Blazor WASM but only with the opensource version

When I try it with suite created project I get these errors. I can zip and send somebody the project.

I´m unable to spot a major difference in config that could be the cause of this and I was also unable to add EnableDetailedErrors so I could maybe get more detailed information.

  • ABP Framework version: 5.2.1
  • UI type: Blazor WASM
  • DB provider: EF Core
  • Identity Server Separated: yes "

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can share the project with me, shiwei.liang@volosoft.com

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You did a wrong thing:

    HttpApi.Host URL is https://localhost:44388

    And you have to change the hub route:

    On the Blazor side, you are using the wrong URL to connect:

    Should be https://localhost:44388/my-messaging-hub.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Try:

    if (tokenResult.TryGetToken(out var token))
    {
        hubConnection = new HubConnectionBuilder()
        .WithUrl("https://localhost:44388/my-messaging-hub", options =>
        {
            options.AccessTokenProvider = () => Task.FromResult(token.Value);
        }).Build();
    
        hubConnection.On<string>("MessageBackToBlazor", (message) =>
                                                                    {
                                                                        Console.WriteLine("Received message from server: " + message);
                                                                        // Comes from Host
                                                                        var encodedMsg = $"Message: {message}";
                                                                        messages.Add(encodedMsg);
                                                                        StateHasChanged();
                                                                    });
        await hubConnection.StartAsync();
    
        await hubConnection.InvokeAsync("SendMessage", "Hello from Blazor!");
    
        state = hubConnection.State.ToString();
    }
    

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11