diff --git a/package-lock.json b/package-lock.json index f288f6f..fc1010b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gateio-api", - "version": "1.0.11", + "version": "1.0.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gateio-api", - "version": "1.0.11", + "version": "1.0.12", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index 09ebb33..0036a3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gateio-api", - "version": "1.0.11", + "version": "1.0.12", "description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.", "scripts": { "clean": "rm -rf dist/*", diff --git a/src/lib/BaseWSClient.ts b/src/lib/BaseWSClient.ts index 236c6ea..3efa84e 100644 --- a/src/lib/BaseWSClient.ts +++ b/src/lib/BaseWSClient.ts @@ -370,7 +370,9 @@ export abstract class BaseWebsocketClient< return { wsKey }; } - if (this.wsStore.isConnectionAttemptInProgress(wsKey)) { + if ( + this.wsStore.isConnectionState(wsKey, WsConnectionStateEnum.CONNECTING) + ) { this.logger.error( 'Refused to connect to ws, connection attempt already active', { ...WS_LOGGER_CATEGORY, wsKey }, @@ -468,6 +470,7 @@ export abstract class BaseWebsocketClient< private reconnectWithDelay(wsKey: TWSKey, connectionDelayMs: number) { this.clearTimers(wsKey); + if (!this.wsStore.isConnectionAttemptInProgress(wsKey)) { this.setWsState(wsKey, WsConnectionStateEnum.RECONNECTING); } diff --git a/src/lib/websocket/WsStore.types.ts b/src/lib/websocket/WsStore.types.ts index c48d22b..280129f 100644 --- a/src/lib/websocket/WsStore.types.ts +++ b/src/lib/websocket/WsStore.types.ts @@ -6,6 +6,7 @@ export enum WsConnectionStateEnum { CONNECTED = 2, CLOSING = 3, RECONNECTING = 4, + // ERROR_RECONNECTING = 5, // ERROR = 5, }