Von English mit KI übersetzt ·
Bildschirmabschaltung bewirkt das nicht. Klassisches WLAN-Energiesparen beim Broadcom-Chip des Pi; ich hatte dasselbe mit einem Pi 3B+ in einem Pumpenhaus. Der Pi schläft nicht, das WLAN schon, und eingehende Pakete werden verzögert oder verloren. Dein paho-Client sendet alle 60 s einen Ping, die Antwort kommt nicht rechtzeitig zurück, Hermetry sieht innerhalb des Keepalive nichts und beendet die Sitzung, daher keepalive_timeout. Dein SSH-Zugriff weckt das Funkmodul auf, deshalb kommt dann alles zurück.
Prüfe das:
iw wlan0 get power_save
Power save: on
Dauerhaft deaktivieren unter Bookworm mit NetworkManager:
sudo tee /etc/NetworkManager/conf.d/wifi-powersave.conf <<EOF
[connection]
wifi.powersave = 2
EOF
sudo systemctl restart NetworkManager
(2 bedeutet deaktiviert.) Wenn du ein älteres Image mit dhcpcd verwendest, füge iw wlan0 set power_save off in ein Skript ein, das nach dem Start des Netzwerks läuft.
Sorge außerdem dafür, dass dein Client sich selbst wieder verbindet: client.reconnect_delay_set(1, 120) und loop_forever oder loop_start, damit sich ein kurzer Verbindungsabbruch von selbst behebt.
Screen blanking won’t do it. Classic Wi-Fi power saving on the Pi’s Broadcom chip, I had the same with a Pi 3B+ in a pump house. The Pi doesn’t sleep, the Wi-Fi does, and incoming packets get delayed or lost. Your paho client sends a ping every 60 s, the answer doesn’t come back in time, Hermetry sees nothing within the keepalive and closes the session, hence keepalive_timeout. Your SSH wakes the radio up, which is why everything comes back then.
Check it:
iw wlan0 get power_save
Power save: on
Turn it off for good on Bookworm with NetworkManager:
sudo tee /etc/NetworkManager/conf.d/wifi-powersave.conf <<EOF
[connection]
wifi.powersave = 2
EOF
sudo systemctl restart NetworkManager
(2 means disabled.) If you’re on an older image with dhcpcd, put iw wlan0 set power_save off in a script that runs after the network is up.
Also make your client reconnect on its own: client.reconnect_delay_set(1, 120) and loop_forever or loop_start, so a short drop fixes itself.

