将 @aspnet/signalr 从1.0.0升级到1.1.2后,调用startConnection() 时出现以下错误:
解析握手响应时出错:TypeError:'instanceof' 的右侧不可调用
这是我的服务:
@Injectable()
export class SignalRService {
careworkerTrckInfo = new EventEmitter<GeoLocationCareWorkerTrackSignalR>();
connectionEstablished = new EventEmitter<Boolean>();
private connectionIsEstablished = false;
private serverTimeoutInMilliseconds = 50000; // 50 Second
private _hubConnection: HubConnection;
constructor(
@Inject(APP_CONFIG) private appConfig: IAppConfig) {
this.createConnection();
this.startConnection();
}
private createConnection() {
const url = `${this.appConfig.apiEndpoint}/notifications`;
this._hubConnection = new HubConnectionBuilder()
.withUrl(url)
.build();
this._hubConnection.serverTimeoutInMilliseconds = this.serverTimeoutInMilliseconds;
}
private startConnection() {
this._hubConnection
.start()
.then(() => {
this.connectionIsEstablished = true;
this.connectionEstablished.emit(true);
})
.catch(err => {
console.log('Error while establishing connection.');
});
}}
它曾经工作过!