Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion images/common/openwisp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,17 @@
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {"hosts": [CHANNEL_REDIS_HOST]},
"CONFIG": {
"hosts": [
{
"address": CHANNEL_REDIS_HOST,
# redis-py 8.0.0 changed the default timeout of socket
# operations to 5 seconds, which breaks django-channels,
# hence we need to explicitly remove the timeout.
"socket_timeout": None,
},
],
},
},
}

Expand Down
14 changes: 14 additions & 0 deletions tests/runtests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import subprocess
import tempfile
Expand Down Expand Up @@ -135,6 +136,19 @@ def test_dashboard_excludes_disabled_radius_api_urls(self):
"Dashboard must not serve disabled RADIUS API URLs.",
)

def test_dashboard_channels_redis_socket_timeout(self):
channel_redis_url = "redis://redis:6379/1"
output, _ = self._execute_django_shell_command(
"from django.conf import settings; import json; print(json.dumps("
"settings.CHANNEL_LAYERS['default']['CONFIG']['hosts'][0]))",
environment={"CHANNEL_REDIS_URL": channel_redis_url},
)
self.assertEqual(
json.loads(output.strip().splitlines()[-1]),
{"address": channel_redis_url, "socket_timeout": None},
"Channels Redis host must have an unlimited socket timeout.",
)


class TestServices(FunctionalTestUtils, unittest.TestCase):
custom_static_token = None
Expand Down