Search code examples
angularsignalrsignalr-hubasp.net-core-signalr

SignalR - can't invoke hub method from client connected to multiple hubs


I setup 2 SignalR connections on the client - one per each hub. Connections are established the following way:

var firstConnection = Signalr.connect();
var secondConnection = Signalr.connect({ hubName: 'MySecondHub' });

Calling hub methods on the default connection works, but when I do...

this.secondConnection.invoke('My2ndHubMethod').then(data => {
     . . . 
});

... it just logs the following in the console SignalRConnection. Start invoking 'My2ndHubMethod'...

Seems like the call never actually returns.

When I change SignalRConfiguration.transport from ConnectionTransports.webSocket to ConnectionTransports.longPolling it produces following error:

Value cannot be null.
Parameter name: s

And logs following to the console Invoking 'My2ndHubMethod' failed. Rejecting promise...

What could be the cause of this?


Solution

  • Apparently the error was caused by Hub1 and Hub2 having different number of arguments in their constructors. Once I put same number and type of arguments for both it started working.