MCPcopy Create free account
hub / github.com/ccxt/node-binance-api / terminateWsApi

Method terminateWsApi

src/node-binance-api.ts:1692–1709  ·  view source on GitHub ↗

* Terminate a WebSocket API connection * @param {string} connectionId - connection identifier * @param {boolean} reconnect - whether to reconnect * @return {undefined}

(connectionId: string, reconnect = false)

Source from the content-addressed store, hash-verified

1690 * @return {undefined}
1691 */
1692 terminateWsApi(connectionId: string, reconnect = false) {
1693 if (this.Options.verbose) this.Options.log('WebSocket API terminating:', connectionId);
1694 const ws = this.wsApiConnections[connectionId];
1695 if (!ws) return;
1696 ws.removeAllListeners('message');
1697 ws.reconnect = reconnect;
1698 ws.terminate();
1699 delete this.wsApiConnections[connectionId];
1700
1701 // Reject all pending requests for this connection
1702 const pendingIds = Object.keys(this.wsApiPendingRequests);
1703 for (const requestId of pendingIds) {
1704 const pending = this.wsApiPendingRequests[requestId];
1705 if (pending && pending.connectionId === connectionId) {
1706 pending.reject(new Error('WebSocket API connection terminated'));
1707 }
1708 }
1709 }
1710
1711 /**
1712 * Futures heartbeat code with a shared single interval tick

Callers 2

stopWsApiConnectionsFunction · 0.80
stopWsApiConnectionsFunction · 0.80

Calls 2

logMethod · 0.80
terminateMethod · 0.65

Tested by 2

stopWsApiConnectionsFunction · 0.64
stopWsApiConnectionsFunction · 0.64