Some code that was working is now less working after a server rebuild, so new packages but same python and relevant configs.
WS works, but now it disconnects if it is idle for a few seconds.
I am guessing this is a clue:
videoteam@kas1:/srv/www/pib/pib$ sudo systemctl status pib-daphne.service
...
Sep 25 16:02:34 kas1 daphne[1129]: redis.exceptions.TimeoutError: Timeout reading from 127.0.0.1:6379
all the things are here, but there are a lot of things so feel free to ask me to dig up the specific details, like the real files off the server, not the ansible templates.
This indicates a problem with the redis connection, not the websocket connection. (Port 6379 is the standard redis port.)
What’s your redis configuration file? (Particularly the timeout and keepalive settings, but eyeball them all.)
What’s your CHANNEL_LAYERS setting?
Check for error messages in the redis log and syslog, along with other messages in the daphne log. (Check the complete log file don’t use systemctl or journalctl)
1133:C 25 Sep 2026 04:17:50.327 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under l
ow memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/iss
ues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_me
mory=1' for this to take effect.
1133:C 25 Sep 2026 04:17:50.327 * Supervised by systemd. Please make sure you set appropriate values for TimeoutStartSec and TimeoutStopSe
c in your service unit.
1133:C 25 Sep 2026 04:17:50.327 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1133:C 25 Sep 2026 04:17:50.327 * Redis version=8.0.2, bits=64, commit=00000000, modified=0, pid=1133, just started
1133:C 25 Sep 2026 04:17:50.327 * Configuration loaded
1133:M 25 Sep 2026 04:17:50.328 * monotonic clock: POSIX clock_gettime
1133:M 25 Sep 2026 04:17:50.329 * Running mode=standalone, port=6379.
1133:M 25 Sep 2026 04:17:50.330 * Server initialized
I don’t have var/log/syslog - isn’t that now in journalctl ?
root@kas1:/var/log/redis# free -h
total used free shared buff/cache available
Mem: 15Gi 1.6Gi 11Gi 8.4Mi 3.3Gi 13Gi
Swap: 6.0Gi 0B 6.0Gi
redis-py 8.0 (pulled in via the unpinned channels_redis dependency) changed the default socket_timeout from None to 5 s. channels_redis waits for websocket messages with a blocking BZPOPMIN that also lasts 5 s. The client therefore gives up at the moment Redis would have answered, and every websocket idle for 5 s is killed. Upstream issue: django/channels_redis#422. The maintainer’s recommended fix is this explicit setting.
tested on the other site, applying to my site now. will post results shortly.
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
# socket_timeout must be None (or longer than the layer's 5 s
# blocking receive): redis-py >= 8 defaults it to 5 s, which
# kills every idle websocket consumer with "Timeout reading from
# 127.0.0.1:6379". See django/channels_redis#422.
"hosts": [{"address": "redis://127.0.0.1:6379", "socket_timeout": None}],
},
},
}
Thanks for taking the time to help, I hope this thread helps others that bump into this too.