Cannot establish a secure WebSocket connection

Hey there, I’m new to Render and I’ve been trying to deploy my NodeJS project at kinnetik.onrender.com. Other than the WebSockets, it seems to be working fine. However… the entire project is based around the WebSockets. I’ve been reading the following posts:

The error I get in the console isn’t really helpful either: RoomSceneController.js:18 WebSocket connection to 'wss://kinnetik.onrender.com/' failed:

I tried the following:

  • Installing Serve with npm install serve
  • Setting environment variables and accessing them through process.env.{NAME}
  • Creating the WebSocket without port, const socket = new WebSocket("wss://kinnetik.onrender.com");
  • Creating the WebSocket with ports, const socket = new WebSocket("wss://kinnetik.onrender.com:9999");. I tried my custom port 9999 and 10000. Both were set accordingly in the Environment variables of the Render project.

As this is my first somewhat advanced NodeJS project and the first time I’m here on Render, I’m (already) out of ideas of what to try next. What are some ideas to try next? Thanks in advance!

So I’ve found the solution. I rewrote the application according to this answer on StackOverflow, and now it works like a charm. I still don’t know what caused the error, although I suspect it has something to do with the ports.

The port your application uses, (9999, 10000, etc.) is only relevant locally. Via public connections to your domain, Render only routes the standard web ports to your application.

If you reference a public domain name, whether your own custom domain name or the app’s name with onrender.com, only ports 80 or 443 will ever be answered.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.