i’ve tried to connect to the server via my local machine and even another server but i get an “timed out” error, sample code that i’m using to connect:
const { WebSocket } = require("ws");
require("dotenv").config();
let ws = new WebSocket(process.env.masterURL); //masterURL being the websocket server
//masterURL: wss://master-ws-server.glitch.me:3000/
what am i doing wrong?
in the server-side, i’m using express and express-ws to create the server
After doing some testing, you may get a 502: Bad Gateway error when connecting to the WebSocket server running on the glitch project. This doesn’t occur when connecting from a web browser.
for the masterURL, do wss://master-ws-server.glitch.me/ instead of wss://master-ws-server.glitch.me:3000/ - By adding the port to a glitch project url, it will not work.
I forgot to remove :3000 in my previous reply at the end. I copied and pasted the code in your initial post, and added the headers part. Sorry for the mistake.