I've been following this http://channels.readthedocs.io/en/latest/getting-started.html
My current setup (before adding channels) was nginx, uwsgi, django.
On my local, I'm running all this on a vagrant box which forwards port 5000
Django server currently runs on 0.0.0.0:5000
My nginx config listens on 8000 and serves static files
It also has:
location / {
include uwsgi_params;
uwsgi_pass unix:{{backend_uwsgi_socket}};
}
While following the tutorial, everything works until I get to the point of changing my settings.py from
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgiref.inmemory.ChannelLayer",
"ROUTING": "myapp.routing.channel_routing",
},
}
to
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
#"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
#"hosts": [("redis-server-name", 6379)],
"hosts": [("localhost", 6379)],
},
"ROUTING": "myapp.routing.channel_routing",
},
}
So the tutorial says to install redis-server, then just run the command again:
manage.py runserver 0.0.0.0:80000
If I turn off nginx, and run this it complains:
ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
I tried adding a listener for this port in my nginx server block, then I get the below error:
^Cvagrant@vagrant-ubuntu-trusty-64:/srv/myproj/backend$ sudo python manage.py runserver 0.0.0.0:8000
Performing system checks...
System check identified no issues (0 silenced).
December 28, 2017 - 17:10:25
Django version 1.10, using settings 'backend.settings'
Starting Channels development server at http://0.0.0.0:8000/
Channel layer default (asgi_redis.core.RedisChannelLayer)
Quit the server with CONTROL-C.
2017-12-28 17:10:25,883 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/dist-packages/channels/management/commands/runserver.py", line 176, in run
worker.run()
File "/usr/local/lib/python2.7/dist-packages/channels/worker.py", line 87, in run
channel, content = self.channel_layer.receive_many(channels, block=True)
File "/usr/local/lib/python2.7/dist-packages/asgiref/base_layer.py", line 43, in receive_many
return self.receive(channels, block)
File "/usr/local/lib/python2.7/dist-packages/asgi_redis/core.py", line 168, in receive
result = connection.blpop(list_names, timeout=self.blpop_timeout)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1269, in blpop
return self.execute_command('BLPOP', *keys)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 668, in execute_command
return self.parse_response(connection, command_name, **options)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 680, in parse_response
response = connection.read_response()
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 624, in read_response
response = self._parser.read_response()
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 292, in read_response
(str(byte), str(response)))
InvalidResponse: Protocol Error: <, html>
After this print out, it just constantly prints the following msg:
ERROR - server - Error trying to receive messages: Protocol Error: <, html>
I'm struggling to find answers for this and have gotten myself confused following a few different tutorials/examples.
I know it will be me having missed something obvious, or have misunderstood something.
Any pointers or help would be greatly appreciated.