Web Socket Wan't Connect
So i have basic websock server running in a simple node.js project, but in production i says it can't connect. I have
wss://mydomain:<port>/
and added my custom domain. But still it wan't let me do it. I will provide the basic websocket server below. It works fine on my local computer.
19 Replies
Project ID:
N/A
N/A
You should listen on the port railway provides to you (
env.PORT
)alright so
const wsServer = new ws.Server({ port: process.env.PORT});
ya
Alright let me test it out
i'd recommend doing this though
that way if no PORT is defined it defaults to 3000 or whatever
what language does the syntax for
env.PORT
come from??I made it up <:chad_moment:758939193967378442>
thats confusing
PORT service variable***
PORT environment variable
variables set in the service are service variables, during build they are called build arguments, during runtime they are environment variables
That is good to know, thank you brody
(unless you set a PORT service variable yourself, the PORT variable generated by railway is only available at runtime as an environment variable)
It's still wan't connect
WebSocket connection to 'wss://websocket.orabot.xyz:8080/' failed
and i have set my domain:remove the port specification at the end of the url
you're not listening on that port
Thanks, let me test it
It works now, thank you!
no problem :D