From 5f4d0dac3cd1dcf9de5fcacfe5fb1195b357c246 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 22 Aug 2018 10:36:36 -0700 Subject: [PATCH] Ignore failures from sending ping (#2840) --- clients/ts/signalr/src/HubConnection.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clients/ts/signalr/src/HubConnection.ts b/clients/ts/signalr/src/HubConnection.ts index f738c6cd8b..1810bc6da4 100644 --- a/clients/ts/signalr/src/HubConnection.ts +++ b/clients/ts/signalr/src/HubConnection.ts @@ -408,7 +408,13 @@ export class HubConnection { this.cleanupPingTimer(); this.pingServerHandle = setTimeout(async () => { if (this.connectionState === HubConnectionState.Connected) { - await this.sendMessage(this.cachedPingMessage); + try { + await this.sendMessage(this.cachedPingMessage); + } catch { + // We don't care about the error. It should be seen elsewhere in the client. + // The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering + this.cleanupPingTimer(); + } } }, this.keepAliveIntervalInMilliseconds); }