The project uses socket.io, the front end is react and the back end is node.js+expresss
There is no problem in the local test. When deployed to the server, an error is reported as shown in the title, and the client cannot connect to the server.
After consulting the document, I realized that the real server ip address must be written to deploy to the server, and the hostname cannot be written.
The original code is as follows:
io.socket = io('ws://localhost:4000')
Then modify the code in react as follows:
io.socket = io('ws://xxxx.xxxx.xxxx.xxxx:4000')
The message can be sent and received successfully, and the problem is solved at this point.