diff --git a/clients/ts/signalr/src/HubConnection.ts b/clients/ts/signalr/src/HubConnection.ts index 749bc6c4f6..ea3d71cd4d 100644 --- a/clients/ts/signalr/src/HubConnection.ts +++ b/clients/ts/signalr/src/HubConnection.ts @@ -406,7 +406,11 @@ export class HubConnection { private resetKeepAliveInterval() { this.cleanupPingTimer(); - this.pingServerHandle = setTimeout(() => this.sendMessage(this.cachedPingMessage), this.keepAliveIntervalInMilliseconds); + this.pingServerHandle = setTimeout(async () => { + if (this.connectionState === HubConnectionState.Connected) { + await this.sendMessage(this.cachedPingMessage); + } + }, this.keepAliveIntervalInMilliseconds); } private resetTimeoutPeriod() {