I get ping event after I send a userDataStream.stop

I use the below code to stop the WebSocket connection after 60 seconds but I continue to receive pings, what’s wrong?

setTimeout(() => {
  ws.send(JSON.stringify({
    "id": "userDataStreamStop",
    "method": "userDataStream.stop",
    "params": {
      "listenKey": listenKey,
      "apiKey": API_KEY
    }
  }));
}, 1 * 60 * 1000);

This method userDataStream.stop tells the Websocket server to stop pushing user data stream, how the websocket connection is not effected. That’s why you can still receive ping message while the connection is still healthy.

If you like to close the connection, send a Close frame to server , then it will be disconnected.

1 Like

Continuing the discussion from I get ping event after I send a userDataStream.stop:Preformatted text