You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am interested in using Channels to support both my HTTP async requests, as well as websockets.
There are millions tutorials out there on how to implement websocket, and that part is very clear to me.
Things change when it comes to implementing HTTP async requests using Channels.
The only example given in the documentation is to set http to django_asgi_app.
I can't find anywhere how to set urlpatterns to the http protocol mentioned, or how attach any routes to be handled through asgi http protocol.
I see that there is such thing as AsyncHttpConsumer however once again, I can't find a way to connect it to the url that I could connect with http protocol.
Would you mind adding an example to documentation of how to use async http with channels, not just websockets?
Thanks a million!
The text was updated successfully, but these errors were encountered:
Hi @Tomislav-Zoricic. To enable "normal" http routes with channels, you only need to have this in asgi.py:
django_asgi_app = get_asgi_application()
application = ProtocolTypeRouter({
# All the normal urls defined in myproject/urls.py are now available
"http": django_asgi_app,
})
And then you need to have "daphne" as the first app in INSTALLED_APPS. Notice daphne takes over the runserver command so it looks like this:
Starting ASGI/Daphne version 4.0.0 development server at http://127.0.0.1:8000/
I am interested in using Channels to support both my HTTP async requests, as well as websockets.
There are millions tutorials out there on how to implement websocket, and that part is very clear to me.
Things change when it comes to implementing HTTP async requests using Channels.
The only example given in the documentation is to set
http
todjango_asgi_app
.I can't find anywhere how to set urlpatterns to the
http
protocol mentioned, or how attach any routes to be handled through asgihttp
protocol.I see that there is such thing as AsyncHttpConsumer however once again, I can't find a way to connect it to the url that I could connect with
http
protocol.Would you mind adding an example to documentation of how to use async
http
with channels, not just websockets?Thanks a million!
The text was updated successfully, but these errors were encountered: