How can pm2 keep multiple connections in front of socket.io from being closed in cluster mode?

  node.js, question

Not long after learning node, it was not a problem for a single connection foreground to use socket.io for websocket connection and event monitoring. However, if pm2 cluster is used to open multiple process/thread modes to handle foreground requests, the console will appear.

failed: Connection closed before receiving a handshake response

How to solve gracefully?
Ps. I don’t want to use nginx as proxy plus the mode of multiple process different ports in the background.

  1. Give up the Long-polling handshake and use the websocket handshake directly, so that there will be no redundant requests falling to different processes and the handshake will fail.
  2. Trouble is trouble, using nginx as proxy,nginx is indeed a good choice.
  3. If nginx’s proxy is not used, nodeJs’s own cluster module can be used, but if Long-polling is used as the starting hand, IP-HASH is required.