I'm new to web development so I appreciate some hand-holding by the smart folks here. I'm trying to switch from gunicorn to Daphne for my Django app on GAE Flex, since I need to use Django Channels.
Previously the site worked fine with gunicorn as entrypoint (in the app.yaml file). I just replaced it with daphne (I'd like to avoid complexity by changing nginx configurations, Unix sockets etc so I guess I'm ok with Daphne serving both HTTP and ws requests). So now my app.yaml looks like:
runtime: python
env: flex
runtime_config:
python_version: 3
entrypoint: daphne -b 0.0.0.0 -p 8001 my_project_name.asgi:application
I've already made a .asgi file next to my .wsgi file and declared an application there.
In requirements.txt I've ensured the daphne(2.4.1) and asgiref(3.2.3) packages are the latest versions.
Finally when I do 'gcloud app deploy', deployment appears to happen smoothly and in the build logs I can see daphne starting:
Step #1: Step 9/9 : CMD exec daphne -b 0.0.0.0 -p 8001 my_project_name.asgi:application
Step #1: ---> Running in c6f3762a5ce2
But I'm getting a 502 Bad Gateway error on the site, with "nginx" in the next line.
Question: What am I doing wrong? Is this because Daphne is not serving http requests? Am I supposed to do anything different to make Daphne serve HTTP requests? Right now my http paths are served in Django by the urls.py module and not the routing.py module (which is taking care of only ws requests). Am I supposed to change that in some way?
If you feel that splitting incoming requests and sending http to gunicorn is the only way, please describe those steps. What happens to the entrypoint in the app.yaml file if I do that?
My efforts so far: I see many questions on SO (such as this and this) and other tutorials online on how to use daphne on standalone linux machines but not on app engines like GAE Flex. The only GAE-related post I saw was this, but it's a different problem from mine.