Skip to content Skip to sidebar Skip to footer

Django Websockets Data Going To The Wrong Socket

Using Django Websockets + Channels, I create a (One) group and the message back and forth works just fine. Lets call this Group A The problem starts when I open a SECOND group and

Solution 1:

So, I figured out what was causing the issues.

The routing was missing as_asgi()

from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.conf.urls import url

from app.consumers import EventConsumer

websocket_urlpatterns = [
    url(r'^events/(?P<id>[^/]+)', EventConsumer().as_asgi()),
]

application = ProtocolTypeRouter({
    'websocket': AuthMiddlewareStack(
        URLRouter(
            websocket_urlpatterns
        )
    ),
})

Post a Comment for "Django Websockets Data Going To The Wrong Socket"