While I was testing my web solutions I found this type of error, this error did not happen to me when I executed the solutions in Visual Studio 2019 since when they were executed the connection was secure, but the error happened to me when the server (Blazor Server) tried to communicate a message to the client (Blazor WebAssembly), the client connected without any problem to Hub
the Blazor Server, but when it did so with the Http protocol without the SSL certificate, it did not allow the client to receive the message. NOTE: The "Client" was created with BlazorWebAssembly and is NOT hosted, they are two different solutions that interact with each other through WebSockets.
My code:
protected override async Task OnInitializedAsync()
{
await ConnectToServer();
}
public async Task ConnectToServer()
{
_connection = new HubConnectionBuilder().WithUrl(Globals.SignaR_Zones).Build();
connectionStatus = "Connected"; isConnected = true;
_connection.Closed += async (s) =>
{
isConnected = false;
connectionStatus = "Disconnected";
await _connection.StartAsync();
isConnected = true;
};
_connection.On<string>("realtime", m =>
{
StateHasChanged();
});
await _connection.StartAsync();
Show(Toaster, MatToastType.Success, "Your are now connected", "Connection");
}