I have a game hosted on vercel, now i needed socket.io for multiplayer. Everything works on localhost, connected to the server on digitalocean. But it does not work when deployed to vercel even though they are talking to the same ip (on digitalocean) I suspect that localhost and digitalocean can talk to eachother since both are http. Vercel is https, so the requests might not go through? In the browser console i receive "WebSocket connection to ‘wss://220.127.116.11:3001/socket.io/?EIO=4&transport=websocket’ failed: " (No failed explanation, its just empty)
So my question is:
Help greatly appreciated ❤️, preferably some in depth guide as i am not a pro with these kind of things
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $200 of credit to try our products over 60 days!
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
Vercel don’t suport websocket client because works as serverless functions returning a bunch of code in each received request, and don’t keep connections alive (necessary for websocket works).
Indeed this sounds like a mixed content problem.
Are you running your web sockets service on a Droplet? If so, as you mentioned, it is best to use a subdomain like
server.example.comand follow these steps:
server.example.comsubdomain to point to your DigitalOcean server IP address.
certbotas described in the tutorial above:
Let me know how it goes!