首页 > 解决方案 > Hubconnection.Invoke 需要几秒钟才能到达服务器

问题描述

我有一个客户端到服务器方法调用的问题,需要几秒钟才能到达服务器。代码很简单:

    this.hubConnection.invoke('OnPendingAlertBadgeCompanyChange', companyId, email)
      .then(_ => {
        Logging.logWithTimestamp(`::: SignalRService => invokeHubForGettingDataForBadgePendingAlerts has been fired. Waiting for data ...`);
        this.gettingDataForBadgePendingAlertsPendingCall = true;
      })
      .catch(reason => {
        this.trowSignalRError(reason)
      }); 

我的印象是连接可能很忙,并且当它空闲时会进行呼叫。

hubConnectionState 无法判断它是否空闲:

export declare enum HubConnectionState {
    /** The hub connection is disconnected. */
    Disconnected = "Disconnected",
    /** The hub connection is connecting. */
    Connecting = "Connecting",
    /** The hub connection is connected. */
    Connected = "Connected",
    /** The hub connection is disconnecting. */
    Disconnecting = "Disconnecting",
    /** The hub connection is reconnecting. */
    Reconnecting = "Reconnecting"
}

这是可能发生的事情吗?

标签: typescriptasp.net-core-signalr

解决方案


推荐阅读