'Why am I getting "No application configured for scope type 'web socket'" still?

I am following , django channels 2 chat app tutorial

I am at the part "writing your first consumer", I exactly did what is in tutorial, you can find my code here

But , I am still unable to connect to my web socket! my error trace :

    HTTP GET /chat/ji/ 200 [0.05, 127.0.0.1:51247]
2018-06-23 07:51:43,181 - ERROR - ws_protocol - [Failure instance: Traceback: <class 'ValueError'>: No application configured for scope type 'websocket'
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/internet/defer.py:500:errback
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/internet/defer.py:567:_startRunCallbacks
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/internet/defer.py:653:_runCallbacks
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/internet/defer.py:1442:gotResult
--- <exception caught here> ---
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/internet/defer.py:1384:_inlineCallbacks
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/python/failure.py:422:throwExceptionIntoGenerator
/anaconda3/envs/chatapp/lib/python3.6/site-packages/daphne/server.py:186:create_application
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/python/threadpool.py:250:inContext
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/python/threadpool.py:266:<lambda>
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/python/context.py:122:callWithContext
/anaconda3/envs/chatapp/lib/python3.6/site-packages/twisted/python/context.py:85:callWithContext
/anaconda3/envs/chatapp/lib/python3.6/site-packages/channels/staticfiles.py:41:__call__
/anaconda3/envs/chatapp/lib/python3.6/site-packages/channels/routing.py:58:__call__
]
Not Found: /favicon.ico
[2018/06/23 07:51:43] HTTP GET /favicon.ico 404 [0.03, 127.0.0.1:51249]
[2018/06/23 07:51:47] WebSocket DISCONNECT /ws/chat/ji/ [127.0.0.1:51248]

I am unable to get where it's going wrong!

My main django project is chatapp, in that chat is an app.

chatapp/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)),
})

chat/routing.py

from django.conf.urls import url
from . import consumers

websocket_urlpatterns = [
    url(r'^ws/chat/(?P<room_name>[^/]+)/$', consumers.ChatConsumer),
]

chat/consumers.py

from channels.generic.websocket import WebsocketConsumer
import json

class ChatConsumer(WebsocketConsumer):

    def connect(self):
        self.accept()

    def disconnect(self, close_code):
        pass

    def receive(self, text_data):
        text_data_json = json.loads(text_data)
        message = text_data_json['message']
        self.send(text_data=json.dumps({
            'message': message
        }))

chat room where I am trying to web socket: chat/templates/room.html

<!-- chat/templates/chat/room.html -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Chat Room</title>
</head>
<body>
    <textarea id="chat-log" cols="100" rows="20"></textarea><br/>
    <input id="chat-message-input" type="text" size="100"/><br/>
    <input id="chat-message-submit" type="button" value="Send"/>
</body>
<script>
    var roomName = {{ room_name_json }};
    var chatSocket = new WebSocket(
        'ws://' + window.location.host +
        '/ws/chat/' + roomName + '/');

    chatSocket.onopen = function(){
   alert('Connection open!');
}
    chatSocket.onmessage = function(e) {
        var data = JSON.parse(e.data);
        var message = data['message'];
        document.querySelector('#chat-log').value += (message + '\n');
    };
    chatSocket.onclose = function(e) {
           if(e.code == 1006)
                console.error('Chat socket closed unexpectedly');

    };
    document.querySelector('#chat-message-input').focus();
    document.querySelector('#chat-message-input').onkeyup = function(e) {
        if (e.keyCode === 13) {  // enter, return
            document.querySelector('#chat-message-submit').click();
} };
    document.querySelector('#chat-message-submit').onclick = function(e) {
        var messageInputDom = document.querySelector('#chat-message-input');
        var message = messageInputDom.value;
        chatSocket.send({
            'message': message
        });
        messageInputDom.value = '';
    };
</script>
</html>

my project structure



Solution 1:[1]

If you are using centos updating redis from version 3 default version in centos to a version that is equal or greater than 6 may help. Worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Japh