1

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? :)

Shai
  • 3,659
  • 2
  • 13
  • 26
user1698635
  • 145
  • 2
  • 12
  • My mistake. I use library for SignalR (@aspnet/signalr) which was .net core. And as my backend is in .net framework web API, it could not work. I just switch back to 'ng2-signalr' library, and everything works perfect. – user1698635 Nov 29 '18 at 14:43

0 Answers0