Websocket not connecting

What could be the potential reasons for a WebSocket connection to fail with the error message “WebSocket connection to ‘wss://your-website.com/socket.io/?EIO=4&transport=websocket&sid=your-session-id’ failed:” and how can it be resolved?

If you have faced similar issues with WebSocket connections, feel free to share your experiences and any solutions you have found to fix the issue. This forum is a place to discuss and troubleshoot problems related to WebSocket connections and to share knowledge and best practices with the community.

Hi! WebSocket issues usually happen because of:

  • Socket.io client and server version mismatch.
  • Firewall misconfiguration.
  • Reverse proxy misconfiguration.
  • Backend failure (aka backend going down).

In order to provide more help, we are going to need more details on your specific issue. Please run pm2 logs --lines 100 on your server and post a screenshot of the error logs while you are connecting.