I fail to have django channels communication with redis running at docker container: I am running the channels tutorial and I get an error when just following the tutorial instructions.
I am quite new with Django (designed a simple site) and have no knowledge on redis nor docker I am trying to lean channels using the tutorial: https://channels.readthedocs.io/en/latest/tutorial/ It uses redis over docker At tutorial part 2 there is a test for “channel layer can communicate with Redis”. I fails this test. I was looking over the web for solving this communication problem with no luck. As I am not familiar with redis nor docker, I have hard time analyzing the reasons for the communication problems. I can see that redis is running inside a docker container. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2bdabc272ec3 redis "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:6379->6379/tcp quizzical_panini $ docker inspect quizzical_panini > redisimage.log (YB: will paste the logfile at the end of this message) python manage.py shell import channels.layers channel_layer = channels.layers.get_channel_layer() from asgiref.sync import async_to_sync async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'}) Error begins with: In [4]: async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'}) --------------------------------------------------------------------------- ConnectionRefusedError Traceback (most recent call last) <ipython-input-4-80e65666e9e2> in <module> ----> 1 async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'}) A lot of other details. Ends up with: 504 # Jump to any except clause below. --> 505 raise OSError(err, f'Connect call failed {address}') 506 except (BlockingIOError, InterruptedError): 507 # socket is still registered, the callback will be retried later ConnectionRefusedError: [Errno 10061] Connect call failed ('127.0.0.1', 6379) Some version details: installing shell command: $ docker run redis --version Redis server v=5.0.3 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=9f27eb593282148b $ pip install channels_redis *A lot of details: ends up with:* > Successfully installed channels-redis-2.3.3 $ python --version Python 3.7.1 (note that it is a 32 bit python while docker requires 64 bits. I assumed it should not be the reason for the problems I do experience >>>>>>>> redisimage.log generated by docker inspect as shown above <<<<<< >>>>>>>> It is long. I can’t tell id/what is relevant [ { "Id": "2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479", "Created": "2019-01-15T14:02:36.679774957Z", "Path": "docker-entrypoint.sh", "Args": [ "redis-server" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 8731, "ExitCode": 0, "Error": "", "StartedAt": "2019-01-15T14:02:37.086931139Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:5d2989ac9711b6c7a96dfca3110041d6259294f5ccd343491ecfffe3d14757cc", "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/resolv.conf", "HostnamePath": "/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/hostname", "HostsPath": "/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/hosts", "LogPath": "/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479-json.log", "Name": "/quizzical_panini", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": null, "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": { "6379/tcp": [ { "HostIp": "", "HostPort": "6379" } ] }, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "shareable", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 30, 129 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "MaskedPaths": [ "/proc/asound", "/proc/acpi", "/proc/kcore", "/proc/keys", "/proc/latency_stats", "/proc/timer_list", "/proc/timer_stats", "/proc/sched_debug", "/proc/scsi", "/sys/firmware" ], "ReadonlyPaths": [ "/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger" ] }, "GraphDriver": { "Data": { "LowerDir": "/mnt/sda1/var/lib/docker/overlay2/37ad581f24c8ec87f199192366c304f952ce27177477746a1d33875a1bd7d7c7-init/diff:/mnt/sda1/var/lib/docker/overlay2/c596b32c9a6bf4a75405f329338e49ff6167970587db8155633861147b0e6b8a/diff:/mnt/sda1/var/lib/docker/overlay2/6d489fac67dc1b566ea6afa79d458d979294142d7f35edd719081e5559d586c1/diff:/mnt/sda1/var/lib/docker/overlay2/5683f690ef322b4d9c02b1bec18880ddc76d48cfebb4a5454143c919dbd3cee8/diff:/mnt/sda1/var/lib/docker/overlay2/d8fd6e07474c264294c0064dda1af0f3c09d7ec35301b8eecacb4ee926a7215b/diff:/mnt/sda1/var/lib/docker/overlay2/cb37f96d8c4d6580faba935057636e928684d73ca58c53136a118918bddbb604/diff:/mnt/sda1/var/lib/docker/overlay2/df686dad04ba90e26a4bd48f64a9911f63547b205c7289d81fb55300aaacdbb4/diff", "MergedDir": "/mnt/sda1/var/lib/docker/overlay2/37ad581f24c8ec87f199192366c304f952ce27177477746a1d33875a1bd7d7c7/merged", "UpperDir": "/mnt/sda1/var/lib/docker/overlay2/37ad581f24c8ec87f199192366c304f952ce27177477746a1d33875a1bd7d7c7/diff", "WorkDir": "/mnt/sda1/var/lib/docker/overlay2/37ad581f24c8ec87f199192366c304f952ce27177477746a1d33875a1bd7d7c7/work" }, "Name": "overlay2" }, "Mounts": [ { "Type": "volume", "Name": "aae85a2f1e19aedc87713b76fca072247d04632ef0c17c44e7dd44ad4e46219c", "Source": "/mnt/sda1/var/lib/docker/volumes/aae85a2f1e19aedc87713b76fca072247d04632ef0c17c44e7dd44ad4e46219c/_data", "Destination": "/data", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" } ], "Config": { "Hostname": "2bdabc272ec3", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "6379/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "GOSU_VERSION=1.10", "REDIS_VERSION=5.0.3", "REDIS_DOWNLOAD_URL= http://download.redis.io/releases/redis-5.0.3.tar.gz", "REDIS_DOWNLOAD_SHA=e290b4ddf817b26254a74d5d564095b11f9cd20d8f165459efa53eb63cd93e02" ], "Cmd": [ "redis-server" ], "ArgsEscaped": true, "Image": "redis", "Volumes": { "/data": {} }, "WorkingDir": "/data", "Entrypoint": [ "docker-entrypoint.sh" ], "OnBuild": null, "Labels": {} }, "NetworkSettings": { "Bridge": "", "SandboxID": "d45841da711498d7de27f9d6050c9b5a873e527cb683075277a9fb8621c1dd30", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "6379/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "6379" } ] }, "SandboxKey": "/var/run/docker/netns/d45841da7114", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "11ad8c469ed5fc9d9ec1b796fe6853b91a8d61915a66f77763073f5f5535000f", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "354ba15e8a867d659da1a3093bd5ddb71df450b6dbb070edf492d980fdaf2c69", "EndpointID": "11ad8c469ed5fc9d9ec1b796fe6853b91a8d61915a66f77763073f5f5535000f", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02", "DriverOpts": null } } } } ] -- Yuval B -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD16PYQvZFt%3DT9Od96LthZD-8cCbfA%2Bf37mXt6icZwVbiiX9Ag%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.