clear pong timer for any incoming data

This commit is contained in:
tiagosiebler
2021-12-31 00:45:50 +00:00
parent 5cd4ab2c36
commit 352f58e09a

View File

@@ -544,6 +544,9 @@ export class WebsocketClient extends EventEmitter {
private onWsMessage(event, wsKey: WsKey) {
try {
// any message can clear the pong timer - wouldn't get a message if the ws dropped
this.clearPongTimer(wsKey);
const msg = JSON.parse(event && event.data || event);
if ('success' in msg || msg?.pong) {
this.onWsMessageResponse(msg, wsKey);
@@ -579,7 +582,6 @@ export class WebsocketClient extends EventEmitter {
private onWsMessageResponse(response: any, wsKey: WsKey) {
if (isWsPong(response)) {
this.logger.silly('Received pong', { ...loggerCategory, wsKey });
this.clearPongTimer(wsKey);
} else {
this.emit('response', response);
}