问题描述
我在客户端上设置了 2 个 SignalR 连接 - 每个集线器一个。通过以下方式建立连接:
var firstConnection = Signalr.connect();
var secondConnection = Signalr.connect({ hubName: 'MySecondHub' });
this.secondConnection.invoke('My2ndHubMethod').then(data => {
. . .
});
...它只是在控制台中记录以下内容
SignalRConnection. Start invoking 'My2ndHubMethod'...
似乎调用从未真正返回。
当我将 SignalRConfiguration.transport
从 ConnectionTransports.webSocket
更改为 ConnectionTransports.longPolling
时,它会产生以下错误:
Value cannot be null.
Parameter name: s
并将以下日志记录到控制台 Invoking 'My2ndHubMethod' Failed. Rejecting promise...
这可能是什么原因?
解决方法
显然该错误是由 Hub1 和 Hub2 在其构造函数中具有不同数量的参数引起的。一旦我为两者设置了相同数量和类型的参数,它就开始工作了。