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:Jump to solution
dont know if thats how it works, you may need to use daphne instead of gunicorn
21 Replies
Project ID:
1ba89116-6373-47f4-9cf9-785a08acae4c
1ba89116-6373-47f4-9cf9-785a08acae4c
I don't need an additional CNAME or anything for this protocol do I?
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
Ok I'll look into how to change http to be 443
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
Okay so it'll just be something like this
wss://your_domain.com:443/your_websocket_endpoint
. Just a port changewell technically you're using wss:// so 443 is implied, specifying it there is a bit redundant
It's already using that without the explicit port though? Not sure why it can't get it and what needs to be configured
show me the current url for the websocket that your app is trying to connect to
wss://decisionchess.com/ws/chat/c5d534db-b06a-4063-81f2-bacf467996b7/
i got a 404
I'll see if I need to update any settings or routing for production
i get this on your site
That's a different websocket and I connect to that one just fine
on the site
alright
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
dont know if thats how it works, you may need to use daphne instead of gunicorn
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
gotcha
Daphne worked! Tried marking solution but it's not letting me
Thanks
no problem!