Closed n2vsb closed 3 years ago
I have the same problem, but I only get ~12 hours or so before I stop getting data. I've got the Pi a bit away from the Wifi point, so I think I'm losing network for a bit. I'm setting the service to restart though, but it never comes back.
As a matter of fact, it's doing it right now:
sudo journalctl -u system_sensors.service
Nov 19 06:04:10 augmntrpi systemd[1]: Started System Sensor service.
Nov 19 06:04:31 augmntrpi python3[698]: Traceback (most recent call last):
Nov 19 06:04:31 augmntrpi python3[698]: File "/home/pi/system_sensors/src/system_sensors.py", line 436, in <module>
Nov 19 06:04:31 augmntrpi python3[698]: mqttClient.connect(settings["mqtt"]["hostname"], settings["mqtt"]["port"])
Nov 19 06:04:31 augmntrpi python3[698]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 9
Nov 19 06:04:31 augmntrpi python3[698]: return self.reconnect()
Nov 19 06:04:31 augmntrpi python3[698]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 1
Nov 19 06:04:31 augmntrpi python3[698]: sock = self._create_socket_connection()
Nov 19 06:04:31 augmntrpi python3[698]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3
Nov 19 06:04:31 augmntrpi python3[698]: return socket.create_connection(addr, source_address=source, timeout=self._k
Nov 19 06:04:31 augmntrpi python3[698]: File "/usr/lib/python3.7/socket.py", line 707, in create_connection
Nov 19 06:04:31 augmntrpi python3[698]: for res in getaddrinfo(host, port, 0, SOCK_STREAM):
Nov 19 06:04:31 augmntrpi python3[698]: File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
Nov 19 06:04:31 augmntrpi python3[698]: for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
Nov 19 06:04:31 augmntrpi python3[698]: socket.gaierror: [Errno -3] Temporary failure in name resolution
Nov 19 06:04:31 augmntrpi systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE
Nov 19 06:04:31 augmntrpi systemd[1]: system_sensors.service: Failed with result 'exit-code'.
Nov 19 06:04:36 augmntrpi systemd[1]: system_sensors.service: Service RestartSec=5s expired, scheduling restart.
Nov 19 06:04:36 augmntrpi systemd[1]: system_sensors.service: Scheduled restart job, restart counter is at 30.
Nov 19 06:04:36 augmntrpi systemd[1]: Stopped System Sensor service.
Nov 19 06:04:36 augmntrpi systemd[1]: Started System Sensor service.
I'm going to up the retry wait time a little more. Here's the current service:
[Unit]
Description=System Sensor service
After=multi-user.target
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
User=pi
Type=idle
ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml
Restart=always
RestartSec=5s
RuntimeMaxSec=900
[Install]
WantedBy=multi-user.target
As a follow-up, this changing RestartSec to 30s cleaned this up.
I'm not also sure why I have RuntimeMaxSec in there, and removed that.
Trying to use this with my Home Assistant setup to monitor 2 remote RPI's. Looking at the information in MQTT explorer, it looks like the MQTT stops sending after about 1 or 2 days. MQTT explorer shows that the 2 RPI's I am trying to monitor through Home Assistant are, "offline" when in fact - they are not and I can access those PI's for their respective use otherwise. Rebooting the PI's brings them back, but only for a day or two again. Is there something with the Birth/LWT of the MQTT that stops it? I have tried to adjust the timing on multiple occasions - but same result? Any thoughts?