Django channels not working on the production environment
I recently deployed a websocket chat app that I developed with Django channels. It works perfectly fine on my local computer even without Daphne web server, but it does not work on production. I followed the docs and installed Daphne, added the configuration on my ProcFile and it still does not work, all I get is a 404 error on every websocket request when I debug. I noticed that my app is still being served with Gunicorn instead of Daphne. Please what am I not doing correctly?
Javascript console error: WebSocket connection to 'wss://sitename.up.railway.app/ws/api/chats/create/?token=750e80203245ee5db475006b6229ca391f836f0f12983939330237' failed:
Project ID: 4713c1f6-1710-4e59-bfc6-2aaa0aaea3e0
ProcFile Configuration:
web: daphne accountGig.asgi:application --port $PORT --bind 0.0.0.0 -v2
Packages :
channels==3.0.4
channels-redis==4.1.0
daphne==3.0.2
Django==4.0.3
gunicorn==20.1.0
11 Replies
Project ID:
4713c1f6-1710-4e59-bfc6-2aaa0aaea3e0
do you have a repo please?
yes i have a private repository
okay screenshot of the repos files please?
here it is
I see the issue, but first, what is the file named
railway
for?It is autogenerated
I didn’t put that there
Please where am I wrong ?
ProcFile --> Procfile
wrong letter casing
Oh 🤦🏽♂️ I’d change that now and try again : )
small nit pick, you have gunicorn in your requirements but are using daphne, you could remove gunicorn right? the less dependencies the faster the build 🙂
Thank you very much I renamed procfile and it worked 🫡
definitely I’d be removing gunicorn now, Although daphne is very slow don’t know how to fasten it 🥲