import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_app_name.settings")
django.setup()
from channels.http import AsgiHandler
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
import chat.routing
application = ProtocolTypeRouter({
"http": AsgiHandler(),
"websocket": AuthMiddlewareStack(
URLRouter(
chat.routing.websocket_urlpatterns
)
),
})
And here is the error returned when I try to deploy :
Mar 12 10:50:39 AM 2021-03-12 10:50:39,398 INFO Starting server at tcp:port=8000:interface=127.0.0.1
Mar 12 10:50:39 AM 2021-03-12 10:50:39,399 INFO HTTP/2 support not enabled (install the http2 and tls Twisted extras)
Mar 12 10:50:39 AM 2021-03-12 10:50:39,399 INFO Configuring endpoint tcp:port=8000:interface=127.0.0.1
Mar 12 10:50:39 AM 2021-03-12 10:50:39,400 INFO Listening on TCP address 127.0.0.1:8000
But the deployment cannot be finalized (it runs indefinetely).
Any idea what I am doing wrong? Is there a problem with the IPs ? Django-channels guidelines indicate we can also specify the port and IP that Daphne binds to. e.g. :
Hey @jpuaux, I think you may have answered your own question! Render services should bind to 0.0.0.0 (all available network interfaces) rather than 127.0.0.1 (localhost). Let us know if you continue to see issues after making that change.
because I am using this command: daphne -b 0.0.0.0 project.asgi:application, I am getting an error in google login but when my
starting command was: gunicorn project.wsgi, google login works perfectly.
You’re getting an Error 400 there from Google - the redirect URL you are requesting is different to what the oAuth client on Google is configured with so Google rejects the request.
Hi im dealing with this issue too. I also need to run daphne and gunicorn because with daphne i can not use csrf. So, i have the same question, how can i run both gunicorn and daphne? Thank you!
hey please i have same problem when my start command is daphne -b 0.0.0.0 root.asgi:application i get an endless deployment sort of loop that never stops deploying. if i change it to this daphne chat.asgi:application --port $PORT --bind 0.0.0.0 it deploys but i get This page isn’t workingepschat.onrender.com redirected you too many times. Try deleting your cookies. ERR_TOO_MANY_REDIRECTS
2024-01-01 22:52:49,281 INFO Starting server at tcp:port=8000:interface=0.0.0.0
2024-01-01 22:52:49,282 INFO HTTP/2 support enabled
2024-01-01 22:52:49,282 INFO Configuring endpoint tcp:port=8000:interface=0.0.0.0
2024-01-01 22:52:49,282 INFO Listening on TCP address 0.0.0.0:8000
Try replacing the port number you use with the default one Render uses when deploying an app. I think it’s 10000.
So instead of daphne --port 8000 --bind 0.0.0.0 myproject.asgi:application,
use daphne --port 10000 --bind 0.0.0.0 myproject.asgi:application.
This worked for me.
Hi guys, I’m currently trying to deploy django channels + celery worker + celery beat , all under one web service. Is this supported by render ? My daphne server starts and seems to work fine but not the celery worker and beat. I was able to achieve this before implementing channels/daphne. I would really appreciate if anyone could advise on this. The start script I am using is the following: