mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Fix WS connection closing
This commit is contained in:
@@ -99,7 +99,9 @@ export default class PriceFeedSubscription<S extends SubscriptionType> {
|
||||
this.callback(parseResult.data);
|
||||
};
|
||||
|
||||
this.ws.onclose = () => this.init();
|
||||
this.ws.onclose = (e) => {
|
||||
if (e.code !== 4000) this.init();
|
||||
};
|
||||
|
||||
this.heartbeatInterval = setInterval(() => {
|
||||
this.ws?.send('heartbeat');
|
||||
@@ -108,6 +110,6 @@ export default class PriceFeedSubscription<S extends SubscriptionType> {
|
||||
|
||||
kill() {
|
||||
if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
|
||||
this.ws?.close();
|
||||
this.ws?.close(4000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user