Django channels - Echo example not working
Question: I'm following the instructions in the [documentation
site](http://channels.readthedocs.io/en/latest/getting-started.html), but I
got stuck in the echo example, the websocket is created correctly and it's
connected to the server but when I send anything to the server I'm not getting
any response (In the example says I should see an alert window with the same
message that I send into the socket but I don't, although I've changed the
alert for a console.log but still), what I'm doing wrong?

In _settings.py_ :

    
    
    INSTALLED_APPS = {
        ...
        'channels',
        'myapp',
        ...
    } 
    
    ...
    # Channels settings
    CHANNEL_LAYERS = {
        "default": {
            "BACKEND": "asgiref.inmemory.ChannelLayer",
            "ROUTING": "myapp.routing.channel_routing",
        },
    }
    

In _routing.py_ :

    
    
    from channels.routing import route
    from myapp.consumers import *
    
    channel_routing = [
        route("websocket.receive", ws_receive),
    ]
    

In _consumers.py_ :

    
    
    def ws_receive(message):
        # ASGI WebSocket packet-received and send-packet message types
        # both have a "text" key for their textual data.
        message.reply_channel.send({
            "text": message.content['text'],
        })
    

In asgi.py

    
    
    import os
    from channels.asgi import get_channel_layer
    
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
    
    channel_layer = get_channel_layer()
    

Then I run: python manage.py runserver, and in my browser I go to the server
url and in the console I put the following:

    
    
    socket = new WebSocket("ws://" + window.location.host + "/chat/");
    socket.onmessage = function(e) {
        alert(e.data);
    }
    socket.onopen = function() {
        socket.send("hello world");
    }
    

Again, at this point I should see an alert window (or the console.log message)
but I get nothing.

[![response](http://i.stack.imgur.com/LqTBA.png)](http://i.stack.imgur.com/LqTBA.png)

The requests that I made have a status of pending (Although I read
[here](http://meta.stackexchange.com/questions/189350/websockets-stuck-in-
pending-on-stack-overflow) and the first comment says it's normal)

[![requests](http://i.stack.imgur.com/NaxTa.png)](http://i.stack.imgur.com/NaxTa.png)

And the server output looks like this:

[![server-
output](http://i.stack.imgur.com/EfFfL.png)](http://i.stack.imgur.com/EfFfL.png)

Every time that I've tried to send something through the websocket in the
browser, the server just print CONNECT but no log from the js console is
showing.

### Edit: I've tested websockets in my browser against echo.websocket.org and
I got the answer as expected:

[![test-
websocket](http://i.stack.imgur.com/VLjX3.png)](http://i.stack.imgur.com/VLjX3.png)


Answer: I changed to an older version of twisted and it fixed it. Hth

