question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recent version of channels doesn't support ASGI3

See original GitHub issue

Since the recent version of daphne (2.3.0) added support for ASGI3, I no longer can’t use channels (2.2.0).

https://github.com/django/daphne/blob/master/daphne/cli.py#L30

Here it would likely to call channel’s router ( ProtocolTypeRouter) with additional two parameters (send, receive) which by now (https://github.com/django/channels/blob/2486738765064525cd8ee39294c44600140476ac/channels/routing.py#L56) is not supported.

Can we have support for ASGI3?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
adamchainzcommented, Dec 23, 2019

N.B. you should be able to wrap Channels ASGI 2 apps with asgiref.compatibility.guarantee_single_callable - https://github.com/django/asgiref/blob/master/asgiref/compatibility.py#L39 - to convert it to ASGI 3.

1reaction
Avinash-Rajcommented, Jul 17, 2019

As for now, I just created subclass of ProtocolTypeRouter like below to support ASGI3.

from channels.routing import ProtocolTypeRouter


class CustomSocketioProtocolTypeRouter(ProtocolTypeRouter):
    """
    Overrided base class's __call__ method to support python socketio 4.2.0 and daphne 2.3.0
    """
    def __call__(self, scope, *args):
        if scope["type"] in self.application_mapping:
            handlerobj = self.application_mapping[scope["type"]](scope)
            if args:
                return handlerobj(*args)
            return handlerobj
        raise ValueError(
            "No application configured for scope type %r" % scope["type"]
        )

application = CustomSocketioProtocolTypeRouter({
    # (http->django views is added by default)
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

3.0.0 Release Notes — Channels 4.0.0 documentation
The Channels 3 update brings Channels into line with Django's own async ASGI support, introduced with Django 3.0. Channels now integrates with Django's ......
Read more >
ASGI_APPLICATION not working with Django Channels
settings' Starting ASGI/Channels version 3.0.5 development server at http://127.0.0.1:8000/ Quit the server with CONTROL ...
Read more >
Channels Documentation - Read the Docs
This tutorial is written for Channels 4.0, which supports Python 3.7+ and Django 3.2+. If the Channels version does not match, you can...
Read more >
Uvicorn
Uvicorn currently supports HTTP/1.1 and WebSockets. ... Not valid with --reload. ... Channels is a little different to other ASGI frameworks in that...
Read more >
channels Changelog - pyup.io
Fixes a bug in Channels 3.0 where ``StaticFilesWrapper`` was not updated to the ASGI 3 ... Updated to ASGI v3, and added support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found