Sunday, 30 December 2018

SignalR Core - Error: Websocket closed with status code: 1006

I use SignalR in an Angular app. When I destroy component in Angular I also want to stop connection to the hub. I use the command:

this.hubConnection.stop();

But I get an error in Chrome console: Websocket closed with status code: 1006

In Edge: ERROR Error: Uncaught (in promise): Error: Invocation canceled due to connection being closed. Error: Invocation canceled due to connection being closed.

It actually works and connection has been stopped, but I would like to know why I get the error.

This is how I start the hub:

this.hubConnection = new HubConnectionBuilder()
      .withUrl("/matchHub")
      .build();

    this.hubConnection.on("MatchUpdate", (match: Match) => {
      // some magic
    })

    this.hubConnection
      .start()
      .then(() => {
        this.hubConnection.invoke("SendUpdates");
      });



from SignalR Core - Error: Websocket closed with status code: 1006

No comments:

Post a Comment