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

Method handleSocketClose

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

* Called when socket is closed, subscriptions are de-registered for later reference * @param {Function} reconnect - reconnect callback * @param {string} code - code associated with the socket * @param {string} reason - string with the response * @return {undefined}

(wsBind, reconnect: Function, code, reason: string)

Source from the content-addressed store, hash-verified

1379 * @return {undefined}
1380 */
1381 handleSocketClose(wsBind, reconnect: Function, code, reason: string) {
1382 delete this.subscriptions[wsBind.url];
1383 if (this.subscriptions && Object.keys(this.subscriptions).length === 0) {
1384 clearInterval(this.socketHeartbeatInterval);
1385 }
1386 this.Options.log('WebSocket closed: ' + wsBind.url +
1387 (code ? ' (' + code + ')' : '') +
1388 (reason ? ' ' + reason : ''));
1389 if (this.Options.reconnect && wsBind.reconnect && reconnect) {
1390 if (wsBind.url && wsBind.url.length === 60) this.Options.log('Account data WebSocket reconnecting...');
1391 else this.Options.log('WebSocket reconnecting: ' + wsBind.url + '...');
1392 try {
1393 reconnect();
1394 } catch (error) {
1395 this.Options.log('WebSocket reconnect error: ' + error.message);
1396 }
1397 }
1398 }
1399
1400 /**
1401 * Called when socket errors

Callers

nothing calls this directly

Calls 2

reconnectFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected