在SignalR 1.1.2中无法调用“ instanceof”的右侧

时间:2019-03-07 08:12:24

标签: angular signalr-client

将@ 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.');
    });
}}

它曾经可以工作!

1 个答案:

答案 0 :(得分:0)

以下代码在我的index.html中:

<script>
    var global = global || window;
    // var Buffer = Buffer || []; --> remove or comment this line
    var process = process || {
        env: {
            DEBUG: undefined
        },
        version: []
    };
</script>

我删除了(注释)缓冲区,它解决了我的问题。