museuminabox / brain

Where the magic happens.
4 stars 0 forks source link

Box tried to ping heart before networking is ready #132

Closed amcewen closed 4 years ago

amcewen commented 4 years ago

When it first boots up, the miab-brain software pings heart to let it know its version, etc.

Now that it starts up quickly, it often manages to try that before the networking has finished connecting to the WiFi (this is probably why Brittany's box hadn't reported that it was at v1.0.0)

You can see the problem if you look at journalctl on the box when sshed in, e.g.:

Feb 03 12:52:07 box wpa_supplicant[380]: wlan0: Trying to associate with SSID 'DoESLiverpool'
Feb 03 12:52:07 box miab-brain[344]: (node:518) Warning: N-API is an experimental feature and could chang
Feb 03 12:52:07 box NetworkManager[381]: <info>  [1580734327.9270] device (wlan0): supplicant interface s
Feb 03 12:52:09 box miab-brain[344]: Web server running on 1880
Feb 03 12:52:09 box miab-brain[344]: OK!  Ready to go
Feb 03 12:52:09 box miab-brain[344]: Update our IP address, version, etc. on Heart
Feb 03 12:52:09 box miab-brain[344]: Failed to find IP address: Error: Command failed: ip addr show wlan0
Feb 03 12:52:09 box miab-brain[344]: { Error: getaddrinfo EAI_AGAIN heart.museuminabox.org:443
Feb 03 12:52:09 box miab-brain[344]:     at Object._errnoException (util.js:1022:11)
Feb 03 12:52:09 box miab-brain[344]:     at errnoException (dns.js:55:15)
Feb 03 12:52:09 box miab-brain[344]:     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
Feb 03 12:52:09 box miab-brain[344]:   code: 'EAI_AGAIN',
Feb 03 12:52:09 box miab-brain[344]:   errno: 'EAI_AGAIN',
Feb 03 12:52:09 box miab-brain[344]:   syscall: 'getaddrinfo',
Feb 03 12:52:09 box miab-brain[344]:   hostname: 'heart.museuminabox.org',
Feb 03 12:52:09 box miab-brain[344]:   host: 'heart.museuminabox.org',
Feb 03 12:52:09 box miab-brain[344]:   port: 443 }
Feb 03 12:52:10 box miab-brain[344]: Tag presented: undefined
Feb 03 12:52:10 box wpa_supplicant[380]: wlan0: Associated with f0:9f:c2:f5:1b:e4

I think the best fix would be to delay the "ping heart" for ~10 seconds, to give the networking time to come up

amcewen commented 4 years ago

Noting here too that using the "update" card will work round this, as it updates the IP address as part of the checking for new content checks.

amcewen commented 4 years ago

Migrated to new repo