0

I'm using Blazor WebAssembly and trying to connect to SignalR server (ASP.NET SignalR, not ASP.NET Core SignalR) using Microsoft.AspNet.SignalR.Client. The code looks like:

var hubConnection = new HubConnection(url, queryString);
await hubConnection.Start();

I get the following exception:

System.PlatformNotSupportedException: Property Credentials is not supported. blazor.webassembly.js:1:37722
  at System.Net.Http.HttpClientHandler.set_Credentials (System.Net.ICredentials value) <0x3c223e0 + 0x0000c> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Http.DefaultHttpHandler..ctor (Microsoft.AspNet.SignalR.Client.IConnection connection) <0x3c1f850 + 0x00040> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Http.DefaultHttpClient.CreateHandler () <0x3c1f000 + 0x00006> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Http.DefaultHttpClient.Initialize (Microsoft.AspNet.SignalR.Client.IConnection connection) <0x3c1eca8 + 0x00010> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.GetNegotiationResponse (Microsoft.AspNet.SignalR.Client.Http.IHttpClient httpClient, Microsoft.AspNet.SignalR.Client.IConnection connection, System.String connectionData) <0x3c1d5c0 + 0x0004c> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Transports.AutoTransport.GetNegotiateResponse (Microsoft.AspNet.SignalR.Client.IConnection connection, System.String connectionData) <0x3c1cc58 + 0x0001e> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Transports.AutoTransport.Negotiate (Microsoft.AspNet.SignalR.Client.IConnection connection, System.String connectionData) <0x3c1cb58 + 0x0000e> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Connection+<>c__DisplayClass153_0.<Negotiate>g__StartNegotiation|1 () <0x3c1c9b0 + 0x0001a> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Connection.Negotiate (Microsoft.AspNet.SignalR.Client.Transports.IClientTransport transport) <0x39ffec0 + 0x0003c> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Connection.Start (Microsoft.AspNet.SignalR.Client.Transports.IClientTransport transport) <0x39e6f10 + 0x000e6> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Connection.Start (Microsoft.AspNet.SignalR.Client.Http.IHttpClient httpClient) <0x39da2a8 + 0x0000e> in <filename unknown>:0 blazor.webassembly.js:1:37722
  at Microsoft.AspNet.SignalR.Client.Connection.Start () <0x39da1e8 + 0x0000c> in <filename unknown>:0 

I don't set the Credentials property of hubConnection, it's null. As far as I can tell from the error message, the client tries to set the Credentials property and this is not supported in Blazor. What can I do to avoid this? I don't need to use Credentials, I'm passing all the server needs in the query string. The same code works fine in a console app.

zdev
  • 75
  • 1
  • 1
  • 4

1 Answers1

0

I managed to overcome this implementing my own HttpClient that doesn't set Credentials, but I still get other errors related to runtime incompatibility. It seems Microsoft.AspNet.SignalR.Client just can't work properly in Blazor/Mono.

zdev
  • 75
  • 1
  • 1
  • 4