Wlan doesn't reconnect automatically

Hello,

I set up a few rpis in our production hall to scan barcode. Unfortunately wifi isn’t very stable. When a raspberry loses the wlan connection it doesn’t reconnect automatically.
We also have a few android smartphone which do the job pretty well. Seems they are able to reconnect automatically.
Any idea how to handle this?

Tryed to set a static ip and ‘wlan0’ in /etc/network/interfaces to ifup over a cron job like mentioned here. Couldn’t get the wlan connection work via ifup.
auto wlan0

iface wlan0 inet static
address 192.1.2.11
netmask 255.255.255.0
network 192.1.2.0
broadcast 192.1.2.255
gateway 192.1.2.1
dns-nameservers 10.10.10.1
wpa-ssid ‘mywlanssid’
wpa-psk ‘thepassword’

(Ubuntu Mate 16.04.2)

Hello @club-mate,

Do you have any log available?

If yes, add here to identify or isolate the problem. :slight_smile:


Two topics that may be able to help you or bring some complementary information:

1 Like

What type of wifi card is it? I have discovered that certain broadcom cards that are in Dell laptops are not compatible with linux. Once I replaced them with intel cards all was well.

Thanks for that quick response!

It’s the raspberry pi build in wifi. Can’t specify because lspci doesn’t work for some reason (‘pcilib: Cannot open /proc/bus/pci’).

Which log do you need? Found something wlan0 related in dmesg:

[ 9.215121] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 9.255770] brcmfmac: brcmf_add_if: ERROR: netdev:wlan0 already exists
[ 9.260594] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 9.706708] brcmfmac: brcmf_add_if: ERROR: netdev:wlan0 already exists
[ 9.740075] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 10.760587] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

Edit

Sounds like “broadcom”…

Do you have the log of cron job you tried to do? On the link you mentioned (/tmp/wifi_reconnect.log)

This behavior just appeared after you try to follow the steps you said in the beginning or only afterwards?

I believe it is a firmware-linked issue, There’s no way to test here but it seems to me that it can help:

https://www.raspberrypi.org/forums/viewtopic.php?p=939041#p939041


Also has a bug reported, still no responses. Can anyone confirm if proceed?

https://bugs.launchpad.net/raspbian/+bug/1646960

wlan0 works via gui setup btw.

First I’d be happy to properly set up wlan so I can ifup/ifdown.
The commands ‘ifup wlan0’ and ‘ifdown wlan0’ seem to work but I can’t ping any server.

/etc/network/interfaces:

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.33
netmask 255.255.255.0
gateway 192.168.0.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid=“myssid”
psk=“password123”
}

dmesg still:

brcmfmac: brcmf_add_if: ERROR: netdev: wlan0 already exists
brcmfmac: brcmf_add_if: ignore IF event

@club-mate

I would recommend that you perform some commands, but I cannot guarantee that they can remedy your problem, but I have researched again with part of what would suggest regarding connectivity.

At the moment I am with a lot of work but I gathered some websites that talk about this point you mentioned:


I hope some of this information or instruction can help you :slight_smile:

Think I’ve got a solution.

Executing this script (wifi_reconnect.sh) every minute:

#!/bin/sh
ping -c2 8.8.8.8 > /dev/null
if [ $? !=0 ]; then
nmcli networking off
sleep 5
nmcli networking on
echo $(date; iwgetid-r) >> reconnect.log
fi

add this line via ‘crontab -e’:

*/1 * * * * sh /root/wifi_reconnect.sh

First tests were promising. Think that’s it.
Thanks again for the support.

1 Like

You are welcome!
Thank you for sharing us also a path to the solution :slight_smile:

1 Like

You don’t have a solution, you have a kludge which worked around the problem.

Ubuntu Mate normally uses Network Manager to manage networking. I don’t use static addresses, so have never explored this under Network Manager, but am sure it would be possible.

What you have in /etc/network/interfaces is a version of Debian networking, and not a reliable version. This can be improved if you use wpa-roam, but even if you get this going it is not as robust as Network Manager.

There are other network managers (Rasbpian used dhcpcd, which is quite robust, but lacks full support in Ubuntu), but I suggest you investigate Network Manager.

Still struggling with the disconnects.
Seems to be a Raspberry Pi 3 related problem. Raspberry Pi 2 works like a charm. How come?

That’s my dmesg when it happens:
[17184.889487] brcmfmac: brcmf_proto_bcdc_query_dcmd: brcmf_proto_bcdc_msg failed w/status -110
[17184.889500] brcmfmac: brcmf_fill_bss_param: Failed to get bss info (-110)
[17187.449506] brcmfmac: brcmf_proto_bcdc_query_dcmd: brcmf_proto_bcdc_msg failed w/status -110
[17197.529474] brcmfmac: brcmf_proto_bcdc_query_dcmd: brcmf_proto_bcdc_msg failed w/status -110
[17200.093210] smsc95xx 1-1.1:1.0 enxb827eb3903b8: hardware isn’t capable of remote wakeup
[17206.393571] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[17206.397577] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[17206.397595] brcmfmac: power management disabled
[17206.405940] IPv6: ADDRCONF(NETDEV_UP): enxb827eb5903b8: link is not ready
[17206.490672] smsc95xx 1-1.1:1.0 enxb827eb3903b8: hardware isn’t capable of remote wakeup
[17206.490787] IPv6: ADDRCONF(NETDEV_UP): enxb827eb5903b8: link is not ready
[17206.730628] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[17234.062008] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready