Robbinet
Posts: 13
Joined: Thu Jan 22, 2015 10:06 am

How to auto reconnect wifi after signal lost

Tue Aug 27, 2019 3:29 pm

Hi,

I am regularly loosing the WiFi connection with as only solutions:
1. Reboot the system
or
2. Unplug and plug the WiFi dongle
All attempts to put the wlan0 interface down and up doesn't solve the problem

Is it a way to ensure the WiFi reconfigure it-self if the WiFi signal was lost for a while?
Thanks in advance
Robert

Here some configuration details

[17:02:41] openhabian@HA_Broker2:~$ cat /etc/debian_version
9.9

[17:03:32] openhabian@HA_Broker2:~$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

[17:04:27] openhabian@HA_Broker2:~$ /opt/vc/bin/vcgencmd version
Mar 27 2019 15:46:32
Copyright (c) 2012 Broadcom
version 2e98b31d18547962e564bdf88e57b3df7085c29b (clean) (release) (start_cd)

[17:08:26] openhabian@HA_Broker2:~$ cat /sys/firmware/devicetree/base/model
Raspberry Pi 2 Model B Rev 1.1[17:09:22] openhabian@HA_Broker2:~$

[17:11:15] openhabian@HA_Broker2:~$ lsusb
Bus 001 Device 007: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Bus 001 Device 004: ID 07ab:fc88 Freecom Technologies
Bus 001 Device 006: ID 6901:2701
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

[17:13:51] openhabian@HA_Broker2:~$ ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:c2:ff:6d txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 28712 bytes 4663517 (4.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28712 bytes 4663517 (4.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.252 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::4e51:3708:f1ac:98b prefixlen 64 scopeid 0x20<link>
inet6 2a02:1811:437:e700:7101:11cb:e58d:303d prefixlen 64 scopeid 0x0<global>
ether 1c:bf:ce:3c:dd:03 txqueuelen 1000 (Ethernet)
RX packets 883 bytes 143781 (140.4 KiB)
RX errors 0 dropped 81 overruns 0 frame 0
TX packets 341 bytes 58722 (57.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[17:16:48] openhabian@HA_Broker2:~$ sudo more /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=BE
network={
ssid="HomeT"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="xxxxxx"
}

epoch1970
Posts: 5022
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to auto reconnect wifi after signal lost

Tue Aug 27, 2019 3:46 pm

Which PSU are you using?
How do you put the interface down, then up, exactly?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Robbinet
Posts: 13
Joined: Thu Jan 22, 2015 10:06 am

Re: How to auto reconnect wifi after signal lost

Tue Aug 27, 2019 5:30 pm

There is no problem with the power supply, (5V 2Amps, most of the time without display and keyboard, but well with USB disk) the system is still running without log message even when the WLAN is down
The command I am using to restart it is:
sudo ifconfig wlan0 down
sudo ifconfig wlan0 up

Next time I will try
sudo service dhcpcd restart
sudo systemctl daemon-reload

In fact the WLAN connection is well automatically restarted after SSID disconnection , so it looks that the interface driver is dead from time to time

The frequency is once or twice per week.
I have a similar dongle running on a debian system (see below) without problem.

pi@HA_Broker:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs

epoch1970
Posts: 5022
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to auto reconnect wifi after signal lost

Tue Aug 27, 2019 6:15 pm

These ifconfig commands should reactivate dhcpcd, I don’t think restarting it will change anything, neither would reloading systemd.

If the combined power to be sent to the USB devices is too high the adapter might stop working. When I want to be sure there is no problem with a PSU I try switching to another one.
If the USB gets disconnected due to lack of power, I think there should be a USB related message in syslog, or perhaps dmesg.
A driver problem for that specific WiFi adapter is a possibility.

To be clear, in normal conditions a WiFi client will reconnect automatically. This is the default behavior.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Robbinet
Posts: 13
Joined: Thu Jan 22, 2015 10:06 am

Re: How to auto reconnect wifi after signal lost

Wed Oct 23, 2019 2:43 pm

After reading a lot of comments regarding this issue, I can't find a solution.

Trying to simulate the problem I did the following:
1. Verify WLAN after boot
pi@HABroker1:~ $ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.253 netmask 255.255.255.0 broadcast 192.168.0.255
.........
2. shutting down WLAN
pi@HABroker1:~ $ sudo ifconfig wlan0 down
pi@HABroker1:~ $ ifconfig wlan0
wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 00:1d:43:30:27:8d txqueuelen 1000 (Ethernet)
..........
3. Starting WLAN
pi@HABroker1:~ $ sudo ifconfig wlan0 up
pi@HABroker1:~ $ ifconfig wlan0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:1d:43:30:27:8d txqueuelen 1000 (Ethernet)
.........
4. looking at WAP_CLI
pi@HABroker1:~ $ wpa_cli
wpa_cli v2.8-devel
Copyright (c) 2004-2019, Jouni Malinen <j@w1.fi> and contributors
........

<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-RESULTS
<3>WPS-AP-AVAILABLE
<3>Trying to associate with 38:43:7d:3f:3f:d5 (SSID='HomeT' freq=2437 MHz)
<3>Association request to the driver failed

All attempt to restart DHCP o the wpa_supplicant don't solve the issue, ONLY a Reboot helps.
Why si the driver not responding?

Example:
sudo wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf
Successfully initialized wpa_supplicant
wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
wlan0: Trying to associate with 38:43:7d:3f:3f:d5 (SSID='HomeT' freq=2437 MHz)
wlan0: Association request to the driver failed

Any Idea how to restart the interface with the SSID (38:43:7d:3f:3f:d5is the MAC address of my Access Point)
Thanks in advance
Robert

User avatar
neilgl
Posts: 2111
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: How to auto reconnect wifi after signal lost

Wed Oct 23, 2019 6:55 pm

What WiFi dongle are you using on that Pi2? - my WIfi dongle works fine (Ralink Technology, Corp. RT5370 Wireless Adapter) on a pi2.
If you have time, I would backup your openhab, then install standard Raspbian on a separate SD card, check wireless, then install openhab2 and restore the backup.

Robbinet
Posts: 13
Joined: Thu Jan 22, 2015 10:06 am

Re: How to auto reconnect wifi after signal lost

Thu Oct 24, 2019 7:29 am

Hi,

I did start from a clean installation of NOOBS 3_2_1 lite with same problem.
Wlan stops to work after a random number of days without a way to just reset the interface.
A Reboot is the only solution
The WiFi adapter I am using is a :
Ralink Technology, Corp. MT7601U Wireless Adapter
I have the same issue with a :
Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

These adapters are working fine since years on a old Raspbeberry configuration :
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

There is a lot of discussions about this issue, which looks to be related to a new Broadcom driver, unfortunately I could not find the way to fix it
An I hope there is one because I can't work with a such unstable Raspberry :evil:

Here are the current infos of my environment:
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

uname -a
Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux

cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 1
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 2
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 3
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 57.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

Hardware : BCM2835
Revision : a01041
Serial : 00000000a5c2ff6d
Model : Raspberry Pi 2 Model B Rev 1.1

lsusb
Bus 001 Device 005: ID 07ab:fc88 Freecom Technologies
Bus 001 Device 007: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Bus 001 Device 006: ID 6901:2701
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hu

Robbinet
Posts: 13
Joined: Thu Jan 22, 2015 10:06 am

Re: How to auto reconnect wifi after signal lost

Wed Nov 27, 2019 10:20 am

OK last feedback after long debugging sessions.
After changing the power supply and the cables, the situation is now becoming stable.
I am currently waiting for a new set of cables to determine if the problem was the cables or the power supply.
So I must admit that the first reply was right and that this is nothing to do with the WIFI driver or the software.
Robert

amcdonley
Posts: 184
Joined: Mon Jan 26, 2015 5:56 pm
Location: Florida, USA

Dongle not reachable, WiFi looks fine - was: How to auto reconnect wifi after signal lost

Fri Jan 24, 2020 11:57 pm

I have similar issue - WiFi Dongle address stops responding (ssh pi@X.0.0.X .. Host is down)
and when I connect with WiFi built-in address X.0.0.Y, everything looks fine in ifconfig - up, no RX or TX errors.

I'm wondering if the issue might be in my WiFi router (Xfinity SCIENTIFIC ATLANTA DPC3941T), not the dongle.

Code: Select all

pi@Carl:~/Carl $ packet_write_poll: Connection to X.0.0.X port 22: Host is down
Mac$ ssh pi@X.0.0.X
ssh: connect to host X.0.0.X port 22: Host is down
Mac$ ssh pi@X.0.0.Y
pi@X.0.0.Y's password: 
Linux Carl 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jan 18 00:44:42 2020 from X.0.0.Z
pi@Carl:~ $ ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:...:86  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 3112  bytes 186720 (182.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3112  bytes 186720 (182.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet X.0.0.X  netmask 255.255.255.0  broadcast X.0.0.255
        inet6 fe80::..1  prefixlen 64  scopeid 0x20<link>
        inet6 26..ff  prefixlen 128  scopeid 0x0<global>
        ether b4..b  txqueuelen 1000  (Ethernet)
        RX packets 2173  bytes 907969974 (865.9 MiB)
        RX errors 0  dropped 258  overruns 0  frame 0
        TX packets 3675  bytes 106031839 (101.1 MiB)
        TX errors 0  dropped 6 overruns 0  carrier 0  collisions 0

wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet X.0.0.Y  netmask 255.255.255.0  broadcast X.0.0.255
        inet6 26...9a  prefixlen 128  scopeid 0x0<global>
        inet6 fe8...ce5  prefixlen 64  scopeid 0x20<link>
        inet6 26...aa  prefixlen 64  scopeid 0x0<global>
        ether b8:...d3  txqueuelen 1000  (Ethernet)
        RX packets 245090  bytes 26383152 (25.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1873  bytes 403869 (394.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi@Carl:~ $ 


Return to “Troubleshooting”