| 859 | * @return {undefined} |
| 860 | */ |
| 861 | const handleFuturesSocketClose = function (reconnect, code, reason) { |
| 862 | delete Binance.futuresSubscriptions[this.endpoint]; |
| 863 | if (Binance.futuresSubscriptions && Object.keys(Binance.futuresSubscriptions).length === 0) { |
| 864 | clearInterval(Binance.socketHeartbeatInterval); |
| 865 | } |
| 866 | Binance.options.log('Futures WebSocket closed: ' + this.endpoint + |
| 867 | (code ? ' (' + code + ')' : '') + |
| 868 | (reason ? ' ' + reason : '')); |
| 869 | if (Binance.options.reconnect && this.reconnect && reconnect) { |
| 870 | if (this.endpoint && parseInt(this.endpoint.length, 10) === 60) Binance.options.log('Futures account data WebSocket reconnecting...'); |
| 871 | else Binance.options.log('Futures WebSocket reconnecting: ' + this.endpoint + '...'); |
| 872 | try { |
| 873 | reconnect(); |
| 874 | } catch (error) { |
| 875 | Binance.options.log('Futures WebSocket reconnect error: ' + error.message); |
| 876 | } |
| 877 | } |
| 878 | }; |
| 879 | |
| 880 | /** |
| 881 | * Called when a futures websocket errors |