aspnetcore: Blazor Client-Side: Unable to create a SignalR connection in a C# Service

Describe the bug

I have set up a hosted Blazor Client-Side Application and have added a SignalR-Connection to my Server (Calling endpoints.MapHub<MyHub>(“/somePath”).

Now I tried to connect to this SignalR-Hub in a C#-Service in ClientSide-Blazor - However, this does not work as expected - I am receiving some strange Exception upon trying to call StartAsync on the HubConnection:

Could not resolve type with token 0100003f from typeref (expected class 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' in assembly 'Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=abd9793829ddae60')

However, when trying to connect to the same hub through JavaScript, it works (as expected) flawlessly, so it’s not a problem of my Hub or Server…

Expected behavior

The Connection should be able to be established without error

Screenshots

I attached some Screenshots with more Information. 2019-08-28_10h25_07 2019-08-28_10h25_43 2019-08-28_10h26_11

The “StartIfNeededAsync”-Method is called on a Razor Page after a Buttonclick:

@inject SignalRService signalr
.....
<button @onclick="start">Test start</button>
...
protected async Task start()
    {
        await signalr.StartIfNeededAsync();
    }

Additional context

Add any other context about the problem here. Include the output of dotnet --info

.NET Core SDK (gemäß “global.json”): Version: 3.0.100-preview8-013656 Commit: 8bf06ffc8d

Laufzeitumgebung: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\

Host (useful for support): Version: 3.0.0-preview8-28405-07 Commit: d01b2fb7bc

.NET Core SDKs installed: 2.0.2 [C:\Program Files\dotnet\sdk] 2.0.3 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.502 [C:\Program Files\dotnet\sdk] 2.1.503 [C:\Program Files\dotnet\sdk] 2.1.505 [C:\Program Files\dotnet\sdk] 2.1.507 [C:\Program Files\dotnet\sdk] 2.1.600-preview-009472 [C:\Program Files\dotnet\sdk] 2.1.700-preview-009597 [C:\Program Files\dotnet\sdk] 2.1.800-preview-009677 [C:\Program Files\dotnet\sdk] 2.1.800-preview-009696 [C:\Program Files\dotnet\sdk] 3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 19 (12 by maintainers)

Most upvoted comments

Yes, it will work in the 3.2 release. We have a plan for making it work.

@ChristianWeyer It’s because .NET’s built-in websockets APIs are built on underlying TCP networking APIs that can’t ever work in the browser, since JavaScript doesn’t expose raw TCP networking capabilities. This naturally leads to a runtime failure from somewhere low in the stack. What we have to do to make it work is provide a browser-compatible implementation of the relevant low-level websocket APIs that are implemented by calling the JavaScript websocket APIs.

As it happens, this work has already been done. We just haven’t integrated it yet. Once it is integrated, my expectation is that the SignalR client should just start working.

We’ll be using this issue to track the work necessary to support SignalR client on Blazor Client-side. So yes, we expect that this will work at some point.