'.NET Core 2.2 - ERR_UNKNOWN_URL_SCHEME - wss://
I have an Angular App with a .NET Core 2.2 Backend, where I've implemented websocket functionality using SignalR.
It worked fine on localhost without ssl, but when using an https page I get the following browser error: ERR_UNKNOWN_URL_SCHEME
The socket is trying to connect to "wss://mypage.net" the page is using https, else it uses the normal ws://mypage URL which is working fine.
When trying to connect from an https page to a ws:// websocket, I get another error because they both have to use SSL I guess. Any ideas why that might be the case?
This is how I establish the connection in Angular:
const url = baseUrl.replace('https://', 'ws://').replace('http://', 'ws://').replace(":4000", ":8990");
this.hubConnection = new signalR.HubConnectionBuilder()
.withUrl(`${url}/apphub`,{
accessTokenFactory: () => this._authService.authentication?.access_token ,
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
}).build();
And in the backend startup.cs:
app.UseSignalR(routes =>
{
routes.MapHub<AppHub>("/apphub");
});
I'm using the NuGet package Microsoft.AspNetCore.SignalR version 1.1.0 in the backend and "@microsoft/signalr": "^5.0.7" in Angular.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

