Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wifi reconnect: doesn't work #64

Closed
biva opened this issue Jun 29, 2017 · 19 comments
Closed

Wifi reconnect: doesn't work #64

biva opened this issue Jun 29, 2017 · 19 comments

Comments

@biva
Copy link

biva commented Jun 29, 2017

Hello,
Thanks for your plugin, but it doesn't work on my config:
Volumio 2.201, Raspbery Pi3, Wifi with fixed IP, Plugin ver 0.0.7
Steps to reproduce

  1. Activate plugin
  2. Disconnect wifi box
  3. Wait for 1 minute
  4. See that the Volumio hotspot has been launched
  5. Reconnect wifi box
  6. Wait for 1 minute
  7. Result: Volumio doesn't reconnect to the box, and the Volumio hotspot is not active anymore
    Any idea?
@biva
Copy link
Author

biva commented Sep 6, 2017

Hello @balbuze
I found a way to make reconnection work. I created a script:

/sbin/ifconfig wlan0 down
/sbin/ifconfig wlan0 up

What is important here, in order to make it work with cron, is to indicate the full path of ifconfig: /sbin/ifconfig.

Then I launch the script with crontab just after my rooter restarts the wifi, every morning at 7:05

5 7 * * * /home/volumio/script_wifi.sh

The script could be optimized to check the internet connection, but I did not test it:

if ! /bin/ping -I wlan0 -c 1 google.com; then
/sbin/ifconfig wlan0 down
/bin/sleep 5
/sbin/ifconfig wlan0 up
fi

And, for the record, here is another way of testing the connection, that I found in a forum. This uses ip instead of ifconfig, which is interesting because ifconfig has been removed from the last version of Debian:

# The IP for the server you wish to ping (8.8.8.8 is a public Google DNS server)
SERVER=8.8.8.8
# Only send two pings, sending output to /dev/null
/bin/ping -c2 ${SERVER} > /dev/null
# If the return code from ping ($?) is not 0 (meaning there was an error)
if [ $? != 0 ]
then
  # Restart the wireless interface
  /sbin/ip link set wlan0 down
  /sbin/ip link set wlan0 up
fi

@balbuze
Copy link
Owner

balbuze commented Sep 6, 2017

hi!
for info : the plugin does not requires cron as it use a systemd timer. And if you want to know the used command, have a look at the file wifireconnect.sh.tmpl and you'll see
#!/bin/bash

SERVER=${serverip}
NINTERFACE=${interface}

ping -c2 ${SERVER} > /dev/null

if [ $? != 0 ]
then
# Restart the wireless interface
ip link set ${NINTERFACE} down
sleep 2
ip link set ${NINTERFACE} up
#systemctl stop wireless.service
#sleep 2
#systemctl start wireless.service

fi
But I'm going to change it with the suggestion from the other issue if it works better...

@balbuze
Copy link
Owner

balbuze commented Sep 6, 2017

should be fixed with the last update ver 0.0.8

@biva
Copy link
Author

biva commented Sep 6, 2017

But I'm going to change it with the suggestion from the other issue if it works better...

Do you mean commands with the full path? I think it's a good idea. Thank you!

I looked at your modifications in https://github.com/balbuze/volumio-plugins/blob/master/plugins/system_controller/wifireconnect/wifireconnect.sh.tmpl I'm not sure which commands should be with the full path:

  • /bin/ping ?
  • /bin/sleep ?
  • /bin/systemctl ?

@biva
Copy link
Author

biva commented Sep 11, 2017

I just installed 0.0.9 on RPI3. It doesn't reconnect either :(
And as it doesn't reconnect, I'm forced to reboot, and then lose the logs. Any idea?

@biva
Copy link
Author

biva commented Sep 11, 2017

I reactivated the hotspot, in order to read the logs here: /var/log/volumio.log

2017-09-11T14:29:32.782Z - info: wifireconnect Daemon Started
2017-09-11T14:29:32.784Z - info: wifireconnect started

They are the only lines concerning wifi or wlan. Is there another log I could share?

@balbuze
Copy link
Owner

balbuze commented Sep 11, 2017

Very weird. I'm using it with a Rpi2 and a usb WiFi dongle. And it reconnects each time I power off/on my router... What is the difference with your settings ?

@balbuze
Copy link
Owner

balbuze commented Sep 11, 2017

I guess you can't plug a screen?

@biva
Copy link
Author

biva commented Sep 12, 2017

Hello, I could plug a screen, but not for too long. What we could do, if you're ok with that, is planning a moment when you're available, and chat on Gitter. I'd have a screen plugged and we could investigate further. I'm available for example today before 1pm (UTC+2), or after 4:30 pm.

@balbuze
Copy link
Owner

balbuze commented Sep 12, 2017

sorry but I was at work... I think we are in the same time zone, maybe tomorrow but later..

@biva
Copy link
Author

biva commented Sep 13, 2017

Thanks, tell me when you're available, I'll do my best

@thalion0
Copy link

thalion0 commented Jan 5, 2018

Don't know if I am correct. The "Wifireconnect service" is calling

ExecStart=/bin/bash /data/plugins/system_controller/wifireconnect/wifireconnect.sh

but this file only containts "empty do not remove". Instead the file "wifireconnect.sh.tmpl" contains the code. Why?

@thalion0
Copy link

thalion0 commented Jan 5, 2018

Okay, I've made some tests. First of all copied wifireconnect.sh.tmpl to wifireconnect.sh and used following content:

#!/bin/bash

SERVER=${serverip}
NINTERFACE=${interface}

# wget -nv --tries=10 --timeout=20 --spider ${SERVER}
ping -c2 ${SERVER} > /dev/null

if [ $? != 0 ]
then
   # Restart the wireless interface
   # ip link set ${NINTERFACE} down
   #       sleep 2
   #   ip link set ${NINTERFACE} up
        #systemctl stop wireless.service
        #sleep 2
        #systemctl start wireless.service
        #sudo /sbin/ifdown --force ${NINTERFACE}
        #sudo /bin/ip link set ${NINTERFACE} up
        systemctl restart wireless
fi

After restart of service I powered off my Access Point and Volumio lost connection. After some seconds Access Point was up again and again some seconds later Volumio connected again.

@balbuze
Copy link
Owner

balbuze commented Jan 5, 2018

Tmpl is the template used to create the sh file. A empty sh exists because it keeps the execute mode when it is filled by the plugin with the template.

@balbuze
Copy link
Owner

balbuze commented Jan 5, 2018

Just add your code in tmpl. The plugin will fill the sh when you save it

@thalion0
Copy link

thalion0 commented Jan 5, 2018

Does not work for me. After fresh install with my changes I see following error. Same without changes by me:

 wifireconnect.service - Wifireconnect service
   Loaded: loaded (/etc/systemd/system/wifireconnect.service; disabled)
   Active: failed (Result: exit-code) since Fri 2018-01-05 13:17:34 UTC; 53s ago
  Process: 3490 ExecStart=/bin/bash /data/plugins/system_controller/wifireconnect/wifireconnect.sh (code=exited, status=127)
 Main PID: 3490 (code=exited, status=127)

Jan 05 13:17:34 radio-flur systemd[1]: Started Wifireconnect service.
Jan 05 13:17:34 radio-flur volumio[3490]: /data/plugins/system_controller/wifireconnect/wifireconnect.sh: line 1: empty: command not found
Jan 05 13:17:34 radio-flur systemd[1]: wifireconnect.service: main process exited, code=exited, status=127/n/a
Jan 05 13:17:34 radio-flur systemd[1]: Unit wifireconnect.service entered failed state.

Because of the "command not found" message I went this way I described earlier with success.

@balbuze
Copy link
Owner

balbuze commented Jan 5, 2018

well, I uploaded a new version that should fix miscellanous problems. !don't froget to save, evenen if you don't change the setting. It's probably the reason of your empty sh file...

@thalion0
Copy link

thalion0 commented Jan 5, 2018

Yep balbuze that's it. Solved for me now and reconnect is working fine.

Thanks a lot!

@balbuze
Copy link
Owner

balbuze commented Jan 5, 2018

good! I close this issue...

@balbuze balbuze closed this as completed Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants