jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.58k stars 768 forks source link

Closing one WebSocket connection inadvertently closes another #900

Open vladimir-cloudypro opened 1 year ago

vladimir-cloudypro commented 1 year ago

Description:

When utilizing two separate WebSocket connections (trades and bookTickers), terminating one with binance.websockets.terminate(pair) causes the other to close as well, despite them being distinct. Additionally, this behavior is observed even when the node-binance-api.js file is duplicated and used separately for each WebSocket.

Steps to Reproduce:

  1. Initialize two separate WebSocket connections: one for trades and one for bookTickers.
  2. Use distinct instances of node-binance-api.js for each WebSocket.
  3. Terminate one of the WebSocket connections using binance.websockets.terminate(pair).
  4. Observe that the other WebSocket connection also closes.

Expected Behavior:

Terminating one WebSocket should not affect the other, especially when they are managed by separate instances of node-binance-api.js.

Actual Behavior:

Terminating one WebSocket connection leads to the inadvertent closure of the other.

Environment:

Node version: 18.18.0 Library version: node-binance-api v0.13.0 OS: macOS 12.7

Additional Information:

Both WebSocket connections are set up and managed independently. The issue persists even after ensuring separate event handlers for each connection. I'm closing the websocket using binance.websockets.terminate(pair)