Topic: Script to auto repair network connection?

For some reason my chumby hates staying on the internet.  It gets into a state where it has network signal (green bars) but it says "Not Connected" in the control panel.  In this state, I can use internet radio but my channels won't load.  The fix is to either reboot or to go through the network wizard again, reselecting my active connection and letting it do its thing so that the control panel figures out that it actually is connected.

Here's what I want:
  * A way to check state of the network the same way the control panel does.
  >>  I've looked as some of the scripts like network_status but that lies.  It will return UP even when the interface is up and as stated in the problem, the interface IS up but the control panel is confused.
  * Once I've detected that the chumby is in this state, I want to "fix" the connection.  Knowing how the control panel checks will make this easier.  Here are some initial thoughts:
  >> Simply call reboot and say screw it.  It's really slow though and kind of a waste considering that it actually IS connected.
  >> Call some script to re-init the control panel.  Is there a safe/sane way to do this?
  >> Write to some file that the control panel is using to check state.  This likely doesn't exist.
  >> Call start_network/restart_network.  I haven't had good luck with this.  The interface doesn't want to come back up but that's probably because I called it from SSH and the session dies when you call it (I tried backgrounding the call but it still didn't work)

Any ideas?  Known solutions (chumby only/no "change your router" responses)?

-Kyle

Re: Script to auto repair network connection?

You may want to reboot your router.  I was having a number of really odd problems with a chumby.  Had to keep reconnecting to the wifi network.  Eventually the problems disappeared after rebooting the wifi router it was connecting with.

Re: Script to auto repair network connection?

I have rebooted my router and tried a static IP and even moved the router.  The thing just doesn't get a strong enough signal I guess.  I just want to make this script and I'll be happiest.

Also, the chumby is the only thing that's having issues.  My laptops, phones and Wii don't have any issues connecting or staying connected.

Re: Script to auto repair network connection?

sadly this is a known problem. chumby has crappy network handling and is unreliable.
here you go -
autoreboot chumby :

crontab -e
0 3 * * * /usr/chumby/scripts/sync_time.sh
* * * * * /usr/chumby/scripts/flashplayer_watchdog
45 * * * * /psp/reboot.sh

vi /psp/reboot.sh
#!/bin/sh

ROUTERIP=192.168.100.1

/bin/ping -c 1 $ROUTERIP > /dev/null
if [[ $? != 0 ]]
then
/usr/chumby/scripts/reboot_normal.sh
fi

touch /psp/reboot.sh

5 (edited by kallanreed 2011-02-13 21:40:15)

Re: Script to auto repair network connection?

Thanks, Zurk.  That's close to what I'm looking but there's one problem which was stated in the initial post.  The adapter is still actually connected or rather gets reconnected without the control panel noticing (it still shows signal bars and the internet radio works).  With the posted script the chumby will be able to ping the router but will still be showing the "no connection clock" and so does not really solve the problem.

What I really need is to find a way to detect the control panel's confused state.  For example: reboot if ping works but some "download chumby channel" flag is unset.  In that case do the reboot.

Is there a way to re-init the network/control panel the same way the network wizard does?  That would be a much nicer solution than a reboot.

Another (not ideal) way would be to just re-init the control panel every hour and the reboot if the ping fails.

EDIT: See this post too: http://forum.chumby.com/viewtopic.php?id=5421

Re: Script to auto repair network connection?

Hmm... nothing huh?

Is the source for the control panel somewhere?

Re: Script to auto repair network connection?

You don't need the CP source - it's just a Flash movie that calls various scripts.

The CP uses the script "network_status.sh" to determine the (surprise!) status of the network, and "signal_strength" to get the information about the wifi.

These scripts (and others related to networking) can be found in /usr/chumby/scripts.

What the CP does is periodically call "network_status.sh" and goes into offline mode when it fails to return a good status - that not only means that the interface is up, but that the system can reach chumby's servers.  When "offline" it wil periodically call this script are go back into normal mode when it succeeds.  If it fails for a long time, it will call "restart_network" then go back into its polling loop.

Re: Script to auto repair network connection?

What are the polling intervals and where are they defined (my first guess is that it would be in the CP source... which is why I asked)?  I'm asking because I've never seen my chumby fix itself even when it's able to connect to Pandora and ShoutCast stations and is showing that it has signal.

If I were to call restart_network manually would the CP get back into the "online" state or does that only happen when the CP initiates the restart_network (yet another question that requires looking at the CP source)

Also, as stated in my first post, the network_status is only returning UP or DOWN.  If the CP were only using network_status, it seems that this should fix itself but I have never seen it fix itself.
  >>  I've looked as some of the scripts like network_status but that lies.  It will return UP even when the interface is up and as stated in the problem, the interface IS up but the control panel is confused.

Re: Script to auto repair network connection?

Hitting "restart_network" manually should work.

The polling interval increases during a failure.  The reason we do that is that if the failure is on the server, we don't want clients pounding it into the dirt when it's trying to come back up.

I'm not sure why you're not seeing it come back up on your device - we have had the occasional scheduled (and sometimes unscheduled) outages of the server, and the server logs indicate that the devices do seem to reconnect by themselves, and we've never had a barrage of people complaining about this (which would be inevitable).