Angular 6 app cannot connect to web API signalR

479 Views Asked by At

I have 'old' project with web api and angular 2. Now I'm switching angular 2 to 6, and have problem with signalR. On angular 2 I used 'ng2-signalr' for angular and it works super. For angualr 6, I'm using '@aspnet/signalr' and this library cannot connect to web api hub. What is confusing, negotiate call is return as 200, but app is not connected to web api, as you can see on following picture. enter image description here

But, I also get following error: enter image description here

Here is code for connecting from angular 6 app:

connectToHub(token: string) {
    var connectionOption = '?token=' + token;
    this.hubConnection = new HubConnectionBuilder()
        .withUrl(environment.apiUrl + 'signalr' + connectionOption)
        .configureLogging(signalR.LogLevel.Information)
        .build();

    this.hubConnection.start()
        .catch((err) => console.log(err));
}

At the end, Angular app cannot connect to web Api hub. Any ideas? :)

0

There are 0 best solutions below