Socket IO
Hello everyone I am facing an issue connecting my app with a railway server through sockets
I'd appreciate if somenone can help me
Solution:Jump to solution
use the same port for http and ws, your app should not be doing https or wss itself, as railway handles the secure part of those transports for you
22 Replies
Project ID:
N/A
n/a
we are using websocket so as I understood I need to use same port for https and wss
socket gateway
weboscket provider
if I set for NEXT_PUBLIC_WSS_URL variable https - socket doesn't work
but If I set wss - socket works but https requests not
btw it works perfectly fine locally with different ports but when we deploy the app it doesn't
anyone?
Solution
use the same port for http and ws, your app should not be doing https or wss itself, as railway handles the secure part of those transports for you
so if i understood you correctly
this should work right?
that would be the correct URL your client would need to use, yes. that will work as long as your server code is done properly
though I can't comment on if the auth is correct
it works if I use seperate instance for ws
but if I try to use the same instance for both https and wss it doesn't work
right but that's obviously not optimal
as mentioned previously, your websockets and http server need to listen on the same port
okay but what is the solution?
having your websockets and http server listen on the same port
they are on the same port already
what port specifically
3000
it needs to be the PORT environment variable
that's the one
you shouldn't be setting it yourself, your app should be listening on it by default
bro I don't understand you
can you please be more specific
the PORT is defined as env variable
what should I do? remove it from there or?
as previously mentioned, you should not be setting the PORT environment variable yourself, your app just simply needs to listen to it as its set automatically for you by railway
got it thanks
will try now without port
thanks bro it works now
:salute:
no problem