I am trying to follow the tutorial here
https://channels.readthedocs.io/en/latest/tutorial/part_2.html and check if channel layer can communicate with Redis. The only different thing I'm doing is that I'm using docker-compose and running the entire thing on a docker container, and that seems to be messing up with everything. This is the error message I'm getting when I try to
run async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/asgiref/sync.py", line 116, in __call__
return call_result.result()
File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/usr/local/lib/python3.7/site-packages/asgiref/sync.py", line 156, in main_wrap
result = await self.awaitable(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/channels_redis/core.py", line 293, in send
async with self.connection(index) as connection:
File "/usr/local/lib/python3.7/site-packages/channels_redis/core.py", line 820, in __aenter__
self.conn = await self.pool.pop()
File "/usr/local/lib/python3.7/site-packages/channels_redis/core.py", line 70, in pop
conns.append(await aioredis.create_redis(**self.host, loop=loop))
File "/usr/local/lib/python3.7/site-packages/aioredis/commands/__init__.py", line 175, in create_redis
loop=loop)
File "/usr/local/lib/python3.7/site-packages/aioredis/connection.py", line 113, in create_connection
timeout)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 414, in wait_for
return await fut
File "/usr/local/lib/python3.7/site-packages/aioredis/stream.py", line 24, in open_connection
lambda: protocol, host, port, **kwds)
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 958, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 945, in create_connection
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 473, in sock_connect
return await fut
File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 503, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 6379)
I've checked a few post and saw that many suggested this is because Redis isn't running. I know that Redis exist since docker ps shows that
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ccab2cfc570 test_web "python manage.py ru…" 7 minutes ago Up 7 minutes 0.0.0.0:8000->8000/tcp test_web_1
6da398f093fc redis:2.8 "docker-entrypoint.s…" 10 minutes ago Up 10 minutes 0.0.0.0:6379->6379/tcp relaxed_aryabhata
Any idea what I can do right now? I'm really new to these
See Question&Answers more detail:
os