binance-api-node
binance-api-node copied to clipboard
Option to disconnect all WebSocket connections
Is there an option to disconnect the client
from all open WebSocket connections? I couldn't find such function in the WebSocket
interface: https://github.com/Ashlar/binance-api-node/blob/0.11.30/index.d.ts#L625
The WebSocket connection method returns the closing function. You can use it to close that connection.
Example:
const wsClose = api.ws.ticker(<symbol>, response => {
console.log(response)
});
// After 10 seconds the ticker websocket will disconnect
setTimeout(() => {
console.log(wsClose())
}, 10000)
Thank you for the hint!
I got it solved now using:
const closeHandler = client.ws.candles('ETHBTC', '1m', candle => {
console.log(candle);
});
closeHandler({delay: 0, fastClose: true, keepClosed: true});