OP-2481 Fix ws subscription issue

This commit is contained in:
Dmitry Leleko
2022-06-30 14:47:04 +03:00
parent 91a22a80be
commit 73eb2044da
2 changed files with 5 additions and 4 deletions

View File

@@ -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

View File

@@ -108,7 +108,7 @@ export default class PriceFeedSubscription<T extends SubscriptionType = Subscrip
this.ws.onclose = (e) => {
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<T extends SubscriptionType = Subscrip
}
kill() {
this.ws?.close(4000);
this.ws?.close();
delete this.ws;
}
}