R
Railway12mo ago
Drekkenz

websocket

I'm trying to have my real-time chat that is using websockets work with Railway with SSL. It's a Django project and I've deployed it to my custom domain that's using https. I can't find anything online about how to configure wss server-side for railway. It's not like I have access to Nginx and can write the config for this. It just says it can't find/create a connection to the websocket server and is trying wss://. My chat is also using Redis that I spun up on railway but I don't think that should be an issue.
Solution:
dont know if thats how it works, you may need to use daphne instead of gunicorn
Jump to solution
21 Replies
Percy
Percy12mo ago
Project ID: 1ba89116-6373-47f4-9cf9-785a08acae4c
Drekkenz
DrekkenzOP12mo ago
1ba89116-6373-47f4-9cf9-785a08acae4c I don't need an additional CNAME or anything for this protocol do I?
Brody
Brody12mo ago
railway does all ssl for you, all you need to do is connect to your websocket endpoint with wss:// and port 443 the app itself has to have the http server and websocket endpoint on the same port
Drekkenz
DrekkenzOP12mo ago
Ok I'll look into how to change http to be 443
Brody
Brody12mo ago
that's not quite what I meant your app should listen on the PORT environment variable (not 443), but you will connect to the app externally from 443
Drekkenz
DrekkenzOP12mo ago
Okay so it'll just be something like this wss://your_domain.com:443/your_websocket_endpoint. Just a port change
Brody
Brody12mo ago
well technically you're using wss:// so 443 is implied, specifying it there is a bit redundant
Drekkenz
DrekkenzOP12mo ago
It's already using that without the explicit port though? Not sure why it can't get it and what needs to be configured
Brody
Brody12mo ago
show me the current url for the websocket that your app is trying to connect to
Drekkenz
DrekkenzOP12mo ago
wss://decisionchess.com/ws/chat/c5d534db-b06a-4063-81f2-bacf467996b7/
Brody
Brody12mo ago
i got a 404
Drekkenz
DrekkenzOP12mo ago
I'll see if I need to update any settings or routing for production
Brody
Brody12mo ago
i get this on your site
No description
Drekkenz
DrekkenzOP12mo ago
That's a different websocket and I connect to that one just fine on the site
Brody
Brody12mo ago
alright
Drekkenz
DrekkenzOP12mo ago
Also that may just be because Django crashed for a bit lol Ahh I think I may know why I've updated it to use asgi for the new websockets so my procfile is now old web: python manage.py collectstatic --noinput && gunicorn decisionchess.wsgi --log-file - I'm guessing just replace it with .asgi
Solution
Brody
Brody12mo ago
dont know if thats how it works, you may need to use daphne instead of gunicorn
Drekkenz
DrekkenzOP12mo ago
Might look into it after trying this, it looks like it's trying to use my new asgi file with that change but early imports don't work as the apps aren't fully loaded yet
Brody
Brody12mo ago
gotcha
Drekkenz
DrekkenzOP12mo ago
Daphne worked! Tried marking solution but it's not letting me Thanks
Brody
Brody12mo ago
no problem!
Want results from more Discord servers?
Add your server