3

I am trying to implement a chat with Django and channels according to this tutorial (http://channels.readthedocs.io/en/latest/tutorial/part_2.html). I add channels and a chat app to installed apps. I make the following routings for a project:

# mysite/routing.py
from channels.routing import ProtocolTypeRouter

application = ProtocolTypeRouter({
    # (http->django views is added by default)
})

Basically, I did exactly the steps from the tutorial. But after runserver I am still getting ValueError: No application configured for scope type 'websocket', after going to a specific chat room. Can please someone help me?

2
  • You updated your settings file? Commented Mar 14, 2018 at 17:03
  • Yes, i did exactly everything from tutorial. Commented Mar 14, 2018 at 17:07

1 Answer 1

14

You appear to be missing the websocket key. The tutorial says to add following imports and add the websocket key in mysite/routing.py.

from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
import chat.routing

application = ProtocolTypeRouter({
    # (http->django views is added by default)
    'websocket': AuthMiddlewareStack(
        URLRouter(
            chat.routing.websocket_urlpatterns
        )
    ),
})
Sign up to request clarification or add additional context in comments.

1 Comment

Nice, actually it was in following section of tutorial. I ended finding solution one chapter before. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.