SIP
MQTT Plugin initialised before network - Printable Version

+- SIP (https://nosack.com/sipforum)
+-- Forum: SIP (Sustainable Irrigation Platform) (https://nosack.com/sipforum/forumdisplay.php?fid=1)
+--- Forum: Report a problem (https://nosack.com/sipforum/forumdisplay.php?fid=9)
+--- Thread: MQTT Plugin initialised before network (/showthread.php?tid=328)



MQTT Plugin initialised before network - cdesouza - 2024 Mar 20

After a reboot the MQTT plugin is intialised before the network is up, more specifically before dhcp has assigned an address


Code:
Mar 20 22:09:04 sip dhcpcd[364]: wlan0: rebinding lease of xxx.xxx.xxx.xxx
Mar 20 22:09:04 sip dhcpcd[364]: wlan0: probing address xxx.xxx.xxx.xxx/24
Mar 20 22:09:04 sip sip[456]: MQTT plugin couldn't initalize client: [Errno 101] Network is unreachable
Mar 20 22:09:04 sip sip[456]: Ignoring exception while loading the telegramBot plug-in.
Mar 20 22:09:04 sip sip[456]: No module named 'telegram'
Mar 20 22:09:05 sip sip[456]: plugins loaded:
Mar 20 22:09:05 sip sip[456]:  advance_control
Mar 20 22:09:05 sip sip[456]:  backup_settings
Mar 20 22:09:05 sip sip[456]:  mobile_app
Mar 20 22:09:05 sip sip[456]:  moisture_sensor_control
Mar 20 22:09:05 sip sip[456]:  moisture_sensor_data_mqtt
Mar 20 22:09:05 sip sip[456]:  mqtt
Mar 20 22:09:05 sip sip[456]:  plugin_manager
Mar 20 22:09:05 sip sip[456]:  relay_board
Mar 20 22:09:05 sip sip[456]:  schedule_data_collector
Mar 20 22:09:05 sip sip[456]:  shutdown_button
Mar 20 22:09:05 sip sip[456]:  simple_chart
Mar 20 22:09:05 sip sip[456]:  system_update
Mar 20 22:09:05 sip sip[456]: Starting timing loop
Mar 20 22:09:05 sip dhcpcd[364]: wlan0: Router Advertisement from xxxx::xxxx:xxxx:xxxx:xxxx
Mar 20 22:09:05 sip dhcpcd[364]: wlan0: adding address xxxx::xxxx:xxxx:xxxx:xxxx /64
Mar 20 22:09:05 sip kernel: ICMPv6: process `dhcpcd' is using deprecated sysctl (syscall) net.ipv6.neigh.wlan0.retrans_time - use net.ipv6.neigh.wlan0.retrans_time_ms inste>
Mar 20 22:09:05 sip dhcpcd[364]: wlan0: adding route to xxxx::xxxx:xxxx:xxxx:xxxx ::/64
Mar 20 22:09:05 sip dhcpcd[364]: wlan0: requesting DHCPv6 information



RE: MQTT Plugin initialised before network - dan - 2024 Mar 22

Looks like the SIP systemd service file should be modified to make sure the network is up before sip starts.

try adding
Code:
After=network-online.target
and
Code:
Wants=network-online.target
to /etc/systemd/system/sip.service.
You will need to disable and re-enable the service for the changes to take effect.

See
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
for more info.


RE: MQTT Plugin initialised before network - cdesouza - 2024 Mar 25

The following change resolved the issue by starting SIP after DHCP has been initialised:

Old
Code:
[Unit]
Description=SIP for Python3
After=syslog.target network.target

New:

Code:
[Unit]
Description=SIP for Python3
After=syslog.target network-online.target
Wants=network-online.target

Thanks for the suggestion.