clear pong timer for any incoming data
This commit is contained in:
@@ -544,6 +544,9 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
|
|
||||||
private onWsMessage(event, wsKey: WsKey) {
|
private onWsMessage(event, wsKey: WsKey) {
|
||||||
try {
|
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);
|
const msg = JSON.parse(event && event.data || event);
|
||||||
if ('success' in msg || msg?.pong) {
|
if ('success' in msg || msg?.pong) {
|
||||||
this.onWsMessageResponse(msg, wsKey);
|
this.onWsMessageResponse(msg, wsKey);
|
||||||
@@ -579,7 +582,6 @@ export class WebsocketClient extends EventEmitter {
|
|||||||
private onWsMessageResponse(response: any, wsKey: WsKey) {
|
private onWsMessageResponse(response: any, wsKey: WsKey) {
|
||||||
if (isWsPong(response)) {
|
if (isWsPong(response)) {
|
||||||
this.logger.silly('Received pong', { ...loggerCategory, wsKey });
|
this.logger.silly('Received pong', { ...loggerCategory, wsKey });
|
||||||
this.clearPongTimer(wsKey);
|
|
||||||
} else {
|
} else {
|
||||||
this.emit('response', response);
|
this.emit('response', response);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user