Anyone create a Xojo app to monitor the Pi Network Connection?

I have my App(s) working fine on the Pi. I have 4 of them. They drop the network connection randomly about every few days.

I’m thinking it would be nice to have a Xojo app that monitors the network connection and if necessary restart it or reboot the pi.

Any thoughts here?

If you want to monitor uptime locally (meaning you’d still have to restart the pi yourself), I use Ping • Network Uptime Monitor for macOS to check servers and notify me.

I don’t see my Pi dropping network connection though, have you tried to debug why that happens?

You could add a timer to each app that (hourly/daily) calls a WebService and reports in. Your WebService could track the status of your devices, and your devices could take action if they can’t reach the WebService. I use this approach on my own devices, and have a structure where a ‘message’ can be staged at the central WebService for each node (device, app) to retrieve when it reports in. This is how I tell remote sites to ‘report in more frequently’, or ‘send me your xyz readings’, or even ‘reboot’.

I’m not sure why they are dropping off the network, my network is fast and stable and I don’t have issues with my other devices.

It’s hard to debug or troubleshoot since I don’t know when or why they go off line. I have connected a monitor and keyboard to one of them and all I can tell is that while it was still running fine, the WiFi Icon at the top looked like it was connected but I couldn’t ping out from it or to it from my computer. I’ve done some searching online and I can see I’m not the only person this happens to. So far, I’ve not found a solution to prevent it which is why I’m thinking trying to write something to check the connection and take the appropriate action to correct it, probably a reboot. The strange thing is, these things aren’t running any tasks when it happens, they are idle with no software running other than the OS.

The thing is, I have not app running when this happens, just the OS. If I don’t find a good solution, I may need to setup something to reboot them when they can’t connect.

mybe there is a wlan power_save enabled by default.

Could be. If there is, I have no idea how to check or set

I Googled around and see something that confirms what @MarkusR mentioned:

iw wlan0 set power_save off

For some reason, my gut says this isn’t going to fix it, but I can’t say why. In any case, I set it up on my 4 Pi’s and we’ll see what happens.

edit: I also think I’ll write a quick app to run on my Mac to show the status and let me know if any of them go off line.

first you should read if it is on as example.
(and you have to use a command line tool that is used for your device.)
iw dev wlan0 get power_save

What network connection is being dropped?

On a DHCP server there may be an address lease duration so if that value expires then a new network (ip) address is given. Could be the cause of your network drop ?

Otherwise there could be a memory leak? or something else that causes the pi network to drop.

Are you using wifi or cable ?

These all have static addresses I assigned at the router. It’s over WiFi.

The dhcp range is not including the static address right ?

It’s an Xfinity modem/router. I let it select the IP address, then I set it to reserved so I always get that address.

1 Like

I wrote a simple app that runs on my Mac, nothing fancy. I hard coded the IP addresses of the 4 Pi’s which have their addresses reserved. I’ve been running it for a few days. If any of the pi’s go down, shows the name which goes red. It’s basically just shelling out to do a ping and checking the result. It seems to be working just fine.

Interestingly enough, none of the Pi’s have gone down while it’s been running except when I was testing it. I did some some stuff online that indicated others have had their pi disconnect from the network if it was sitting idle for too long. Perhaps the occasional ping from my app is enough to keep them from dropping the connection due to inactivity. That’s just a guess based on what I’ve read and am experiencing. I’ll continue to run it see how long they stay connected.

try to read the power save mode of the wlan device.

My router doesn’t seem to have a power save mode.

My router doesn’t seem to have a power save mode.

i meant your Raspberry Pi.
for practical reason i guess you use wireless LAN.

The searches I’ve done say the pi. Doesn’t have a power saving mode. I’d check that if it does and knew how. Yes they are wireless as I just play around with them and they are all within 10 feet of the router.

Well my Pi Monitoring app running on the Mac using Pings to each pi at regular intervals, caught 3 out of my 4 Pi’s offline this morning. I noticed that all 4 were showing that Updates were available. I rebooted 2 of them, and turned the WiFi off and back on for the 3rd one that was down and it reconnected no problem. I’m not sure if the available updates have anything to do with the issue, but it seems to be common when it happens. A reboot of the pi or restart of the WiFi does get things reconnected.

The next thing I’d like to do is write an app to run on each pi monitoring connectivity. If the network connection down, first try toggling the WiFi connection and then check again. If that doesn’t work, reboot the pi which always seems to work. Shouldn’t be too hard to write this app, just need to sit down and do it.