From 73eb2044da903fbaa1b2cd3ee95341eaa8052ee1 Mon Sep 17 00:00:00 2001 From: Dmitry Leleko Date: Thu, 30 Jun 2022 14:47:04 +0300 Subject: [PATCH] OP-2481 Fix ws subscription issue --- src/services/OrionAggregator/ws/index.ts | 4 ++-- src/services/PriceFeed/ws/PriceFeedSubscription.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/services/OrionAggregator/ws/index.ts b/src/services/OrionAggregator/ws/index.ts index 27611e2..4ea7e0b 100644 --- a/src/services/OrionAggregator/ws/index.ts +++ b/src/services/OrionAggregator/ws/index.ts @@ -254,14 +254,14 @@ class OrionAggregatorWS { } destroy() { - this.ws?.close(4000); + this.ws?.close(); delete this.ws; } init(isReconnect = false) { this.ws = new WebSocket(this.wsUrl); this.ws.onclose = (e) => { - if (e.code !== 4000) this.init(true); + if (this.ws) this.init(true); }; this.ws.onopen = () => { // Re-subscribe to all subscriptions diff --git a/src/services/PriceFeed/ws/PriceFeedSubscription.ts b/src/services/PriceFeed/ws/PriceFeedSubscription.ts index 4530915..513f9f8 100644 --- a/src/services/PriceFeed/ws/PriceFeedSubscription.ts +++ b/src/services/PriceFeed/ws/PriceFeedSubscription.ts @@ -108,7 +108,7 @@ export default class PriceFeedSubscription { if (this.heartbeatInterval) clearInterval(this.heartbeatInterval); - if (e.code !== 4000) this.init(); + if (this.ws) this.init(); }; this.heartbeatInterval = setInterval(() => { @@ -117,6 +117,7 @@ export default class PriceFeedSubscription