Device keeps disconnecting from Wi-Fi (deauthenticated due to inactivity)

My Huawei P20 Pro keeps disconnecting from my Wi-Fi network. I have 2 routers, an Archer A6 (23.05) and TL-WR940N (used as a repeater, 19.07.9). This issue happens on both routers, but I'm pretty sure it didn't happen before. These are the logs from the phone:

03-23 13:20:01.860 15568 15568 D wpa_supplicant: nl80211: Roam event
03-23 13:20:01.860 15568 15568 D wpa_supplicant: nl80211: current bssid e4:**:**:**:ba:03
03-23 13:20:01.860 15568 15568 D wpa_supplicant: nl80211: Set drv->ssid based on req_ie to 'Andrei'
03-23 13:20:01.864 15568 15568 D wpa_supplicant: nl80211: Associated with 52:**:**:**:0d:0a
03-23 13:20:01.865 15568 15568 D wpa_supplicant: nl80211: Operating frequency for the associated BSS from scan results: 2412 MHz
03-23 13:20:01.865 15568 15568 D wpa_supplicant: wlan0: Event ASSOC (0) received
03-23 13:20:01.865 15568 15568 D wpa_supplicant: wlan0: Association info event
03-23 13:20:01.865 15568 15568 D wpa_supplicant: wlan0: freq=2412 MHz
03-23 13:20:01.865 15568 15568 D wpa_supplicant: RSN: PMKSA cache search - network_ctx=(nil) try_opportunistic=0 akmp=0x0
03-23 13:20:01.865 15568 15568 D wpa_supplicant: RSN: No PMKSA cache entry found
03-23 13:20:01.865 15568 15568 D wpa_supplicant: wlan0: RSN: PMKID from assoc IE not found from PMKSA cache
03-23 13:20:01.865 15568 15568 D wpa_supplicant: FT: Capability and Policy: 0x00
03-23 13:20:01.865 15568 15568 D wpa_supplicant: wlan0: State: COMPLETED -> ASSOCIATED
03-23 13:20:01.865 15568 15568 D wpa_supplicant: mdpp-wpa: MDPP switch is off
03-23 13:20:01.869 15568 15568 D wpa_supplicant: set wlan mtu to 1500
03-23 13:20:01.877 15568 15568 D wpa_supplicant: Notifying state change event to hidl control: 6
03-23 13:20:01.877 15568 15568 D wpa_supplicant: wlan0: freq[0]: 2412, flags=0x1
03-23 13:20:01.877 15568 15568 D wpa_supplicant: P2P: channels: 81:1,2,3,4,5,6,7,8,9,10,11,12,13 115:36,40,44,48 124:149,153,157,161 125:149,153,157,161,165 130:36,40,44,48
03-23 13:20:01.877 15568 15568 D wpa_supplicant: wlan0: Associated to a new BSS: BSSID=52:**:**:**:0d:0a
03-23 13:20:01.877 15568 15568 D wpa_supplicant: Notifying bssid changed to hidl control
03-23 13:20:01.887 15568 15568 D wpa_supplicant:    addr=52:**:**:**:0d:0a
03-23 13:20:01.890 15568 15568 D wpa_supplicant: wlan0: WPA: clearing AP WPA IE
03-23 13:20:01.890 15568 15568 I wpa_supplicant: wlan0: Associated with 52:**:**:**:0d:0a
03-23 13:20:01.890 15568 15568 D wpa_supplicant: wlan0: WPA: Association event - clear replay counter
03-23 13:20:01.890 15568 15568 D wpa_supplicant: wlan0: WPA: Clear old PTK
03-23 13:20:01.890 15568 15568 D wpa_supplicant: TDLS: Remove peers on association
03-23 13:20:01.894 15568 15568 D wpa_supplicant: wlan0: Setting authentication timeout: 10 sec 0 usec
03-23 13:20:01.894 15568 15568 D wpa_supplicant: wlan0: Cancelling scan request
03-23 13:20:01.894 15568 15568 I wpa_supplicant: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
03-23 13:20:03.645 15568 15568 D wpa_supplicant: nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0
03-23 13:20:03.645 15568 15568 D wpa_supplicant: wlan0: nl80211: Scan trigger
03-23 13:20:03.645 15568 15568 D wpa_supplicant: wlan0: Event SCAN_STARTED (46) received
03-23 13:20:03.645 15568 15568 D wpa_supplicant: wlan0: External program started a scan
03-23 13:20:03.896 15568 15568 D wpa_supplicant: EAPOL: txStart
03-23 13:20:03.896 15568 15568 D wpa_supplicant: WPA: drop TX EAPOL in non-IEEE 802.1X mode (type=1 len=0)
03-23 13:20:08.180 15568 15568 D wpa_supplicant: nl80211: Drv Event 34 (NL80211_CMD_NEW_SCAN_RESULTS) received for wlan0
03-23 13:20:08.180 15568 15568 D wpa_supplicant: wlan0: nl80211: New scan results available
03-23 13:20:08.180 15568 15568 D wpa_supplicant: nl80211: Scan probed for SSID ''
03-23 13:20:08.180 15568 15568 D wpa_supplicant: nl80211: Scan included frequencies: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 5180 5200 5220 5240 5260 5280 5300 5320 5500 5520 5540 5560 5580 5600 5620 5640 5660 5680 5700 5745 5765 5785 5805 5825
03-23 13:20:08.180 15568 15568 D wpa_supplicant: wlan0: Event SCAN_RESULTS (3) received
03-23 13:20:08.180 15568 15568 D wpa_supplicant: nl80211: Received scan results (6 BSSes)
03-23 13:20:08.180 15568 15568 D wpa_supplicant: nl80211: Scan results indicate BSS status with 52:**:**:**:0d:0a as associated
03-23 13:20:08.181 15568 15568 D wpa_supplicant: wlan0: BSS: Start scan result update 7
03-23 13:20:08.181 15568 15568 D wpa_supplicant: BSS: last_scan_res_used=6/32
03-23 13:20:08.181 15568 15568 D wpa_supplicant: wlan0: New scan results available (own=0 ext=1)
03-23 13:20:08.181 15568 15568 D wpa_supplicant: wlan0: Do not use results from externally requested scan operation for network selection
03-23 13:20:08.181 15568 15568 D wpa_supplicant: p2p-dev-wlan0: Updating scan results from sibling
03-23 13:20:08.181 15568 15568 D wpa_supplicant: nl80211: Received scan results (6 BSSes)
03-23 13:20:08.181 15568 15568 D wpa_supplicant: p2p-dev-wlan0: BSS: Start scan result update 7
03-23 13:20:08.181 15568 15568 D wpa_supplicant: BSS: last_scan_res_used=6/32
03-23 13:20:08.181 15568 15568 D wpa_supplicant: p2p-dev-wlan0: New scan results available (own=0 ext=1)
03-23 13:20:08.181 15568 15568 D wpa_supplicant: p2p-dev-wlan0: Do not use results from externally requested scan operation for network selection
03-23 13:20:08.698 15568 15568 D wpa_supplicant: nl80211: Drv Event 33 (NL80211_CMD_TRIGGER_SCAN) received for wlan0
03-23 13:20:08.698 15568 15568 D wpa_supplicant: wlan0: nl80211: Scan trigger
03-23 13:20:08.698 15568 15568 D wpa_supplicant: wlan0: Event SCAN_STARTED (46) received
03-23 13:20:08.698 15568 15568 D wpa_supplicant: wlan0: External program started a scan
03-23 13:20:11.895 15568 15568 I wpa_supplicant: wlan0: Authentication with 52:**:**:**:0d:0a timed out.
03-23 13:20:11.895 15568 15568 D wpa_supplicant: Added BSSID 52:**:**:**:0d:0a into blacklist
03-23 13:20:11.896 15568 15568 D wpa_supplicant: TDLS: Remove peers on disassociation
03-23 13:20:11.896 15568 15568 D wpa_supplicant: wlan0: WPA: Clear old PMK and PTK
03-23 13:20:11.896 15568 15568 D wpa_supplicant: wlan0: Request to deauthenticate - bssid=52:**:**:**:0d:0a pending_bssid=00:**:**:**:00:00 reason=3 state=ASSOCIATED
03-23 13:20:11.917 15568 15568 D wpa_supplicant: wlan0: Event DEAUTH (11) received
03-23 13:20:11.917 15568 15568 D wpa_supplicant: wlan0: Deauthentication notification
03-23 13:20:11.918 15568 15568 D wpa_supplicant: wlan0:  * reason 3 (locally generated)
03-23 13:20:11.918 15568 15568 I wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED bssid=52:**:**:**:0d:0a reason=3 locally_generated=1
03-23 13:20:11.923 15568 15568 D wpa_supplicant: wlan0: Auto connect disabled: do not try to re-connect
03-23 13:20:11.923 15568 15568 D wpa_supplicant: wlan0: Ignore connection failure indication since interface has been put into disconnected state
03-23 13:20:11.923 15568 15568 D wpa_supplicant: TDLS: Remove peers on disassociation
03-23 13:20:11.923 15568 15568 D wpa_supplicant: wlan0: WPA: Clear old PMK and PTK
03-23 13:20:11.923 15568 15568 D wpa_supplicant: Notifying disconnect reason to hidl control: -3
03-23 13:20:11.929 15568 15568 D wpa_supplicant: wlan0: Disconnect event - remove keys
03-23 13:20:11.935 15568 15568 D wpa_supplicant: wlan0: State: ASSOCIATED -> DISCONNECTED
03-23 13:20:11.935 15568 15568 D wpa_supplicant: mdpp-wpa: MDPP switch is off
03-23 13:20:11.935 15568 15568 D wpa_supplicant: Notifying state change event to hidl control: 0
03-23 13:20:11.935 15568 15568 D wpa_supplicant: P2P: channels: 81:1,2,3,4,5,6,7,8,9,10,11,12,13 115:36,40,44,48 124:149,153,157,161 125:149,153,157,161,165 130:36,40,44,48
03-23 13:20:11.936 15568 15568 D wpa_supplicant: wpa_supplicant_set_block_frame: drv_cmd: SETBLOCKFRAME 0 0, ret=3
03-23 13:20:11.936 15568 15568 D wpa_supplicant: wlan0: SME: Remove mobility domain
03-23 13:20:11.936 15568 15568 D wpa_supplicant: Notifying bssid changed to hidl control
03-23 13:20:11.944 15568 15568 D wpa_supplicant: wlan0: State: DISCONNECTED -> DISCONNECTED

Archer A6:

Sat Mar 23 13:55:46 2024 daemon.info hostapd: phy1-ap0: STA 88:11:96:cb:3a:d3 IEEE 802.11: authenticated
Sat Mar 23 13:55:46 2024 daemon.info hostapd: phy1-ap0: STA 88:11:96:cb:3a:d3 IEEE 802.11: associated (aid 4)
Sat Mar 23 13:55:46 2024 daemon.notice hostapd: phy1-ap0: AP-STA-CONNECTED 88:11:96:cb:3a:d3 auth_alg=open
Sat Mar 23 13:55:46 2024 daemon.info hostapd: phy1-ap0: STA 88:11:96:cb:3a:d3 WPA: pairwise key handshake completed (RSN)
Sat Mar 23 13:55:46 2024 daemon.notice hostapd: phy1-ap0: EAPOL-4WAY-HS-COMPLETED 88:11:96:cb:3a:d3
Sat Mar 23 13:55:47 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.0.219 88:11:96:cb:3a:d3
Sat Mar 23 13:55:47 2024 daemon.info dnsmasq-dhcp[1]: DHCPACK(br-lan) 192.168.0.219 88:11:96:cb:3a:d3 HUAWEI_P20_Pro-a18f18baa4
Sat Mar 23 13:55:47 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.0.219 88:11:96:cb:3a:d3
Sat Mar 23 13:55:47 2024 daemon.info dnsmasq-dhcp[1]: DHCPACK(br-lan) 192.168.0.219 88:11:96:cb:3a:d3 HUAWEI_P20_Pro-a18f18baa4
Sat Mar 23 14:01:14 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.0.114 c0:cb:f1:33:b6:cf
Sat Mar 23 14:01:14 2024 daemon.info dnsmasq-dhcp[1]: DHCPACK(br-lan) 192.168.0.114 c0:cb:f1:33:b6:cf MyOS
Sat Mar 23 14:03:51 2024 daemon.notice hostapd: phy1-ap0: AP-STA-DISCONNECTED 88:11:96:cb:3a:d3
Sat Mar 23 14:03:51 2024 daemon.info hostapd: phy1-ap0: STA 88:11:96:cb:3a:d3 IEEE 802.11: disassociated due to inactivity
Sat Mar 23 14:03:52 2024 daemon.info hostapd: phy1-ap0: STA 88:11:96:cb:3a:d3 IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)

TL-WR940N:

Sat Mar 23 11:13:07 2024 daemon.info hostapd: wlan0-1: STA 88:11:96:cb:3a:d3 IEEE 802.11: associated (aid 6)
Sat Mar 23 11:13:07 2024 daemon.notice hostapd: wlan0-1: AP-STA-CONNECTED 88:11:96:cb:3a:d3
Sat Mar 23 11:13:17 2024 daemon.notice hostapd: wlan0-1: AP-STA-DISCONNECTED 88:11:96:cb:3a:d3
Sat Mar 23 11:13:17 2024 daemon.info hostapd: wlan0-1: STA 88:11:96:cb:3a:d3 IEEE 802.11: disassociated
Sat Mar 23 11:13:18 2024 daemon.info hostapd: wlan0-1: STA 88:11:96:cb:3a:d3 IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)

These messages keep repeating every few minutes, and the phone never stays connected longer than that. Also, I haven't seen this issue on any other device.

1 Like

Then perhaps it's a phone issue ?

I think so, but it never happened before on this phone. Something like this also happens on my Kali Linux laptop, where one second the signal is full, next second it is weak or zero. I hope there's a fix, it's driving me nuts.

It looks like the phone received a deauth that the AP did not send. Is it possible someone is maliciously interfering with you? Try turning on MFP (ieee80211w) if it is not already on.

Let's see some of the config info from each device:

Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

ubus call system board
cat /etc/config/network
cat /etc/config/wireless

I doubt it. Also I don't think I can enable MFP since I have wpad-basic

Archer A6

root@OpenWrt:~# ubus call system board
{
        "kernel": "5.15.134",
        "hostname": "OpenWrt",
        "system": "Qualcomm Atheros QCA956X ver 1 rev 0",
        "model": "TP-Link Archer C6 v2 (EU/RU/JP)",
        "board_name": "tplink,archer-c6-v2",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "23.05.0",
                "revision": "r23497-6637af95aa",
                "target": "ath79/generic",
                "description": "OpenWrt 23.05.0 r23497-6637af95aa"
        }
}
root@OpenWrt:~# cat /etc/config/network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd5f:28d9:3fa3::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0.1'
        option stp '1'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.0.1'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option stp '1'

config interface 'wan'
        option device 'eth0.2'
        option proto 'dhcp'
        option macaddr 'E4:C3:2A:86:BA:04'

config interface 'wan6'
        option device 'eth0.2'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '2 3 4 5 0t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '1 0t'

config interface 'tun0'
        option proto 'dhcp'
        option device 'tun0'

root@OpenWrt:~# cat /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'pci0000:00/0000:00:00.0'
        option channel '36'
        option band '5g'
        option htmode 'VHT80'
        option disabled '1'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'

config wifi-device 'radio1'
        option type 'mac80211'
        option path 'platform/ahb/18100000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option cell_density '0'
        option txpower '20'

config wifi-iface 'default_radio1'
        option device 'radio1'
        option network 'lan'
        option mode 'ap'
        option ssid 'Andrei'
        option encryption 'psk2'
        option wds '1'
        option disassoc_low_ack '0'
        option key 'password'
        option ieee80211r '1'
        option mobility_domain '6C78'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option skip_inactivity_poll '1'

TL-WR940N

root@Bucatarie-RPT:~# ubus call system board
{
        "kernel": "4.14.267",
        "hostname": "Bucatarie-RPT",
        "system": "Qualcomm Atheros TP9343 rev 0",
        "model": "TP-Link TL-WR940N v6",
        "board_name": "tl-wr940n-v6",
        "release": {
                "distribution": "OpenWrt",
                "version": "19.07.9",
                "revision": "r11405-2a3558b0de",
                "target": "ar71xx/tiny",
                "description": "OpenWrt 19.07.9 r11405-2a3558b0de"
        }
}
root@Bucatarie-RPT:~# cat /etc/config/network

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdce:5ac6:4b65::/48'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth1.1'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option stp '1'
        option igmp_snooping '1'
        option ipaddr '192.168.0.150'
        option gateway '192.168.0.1'

config interface 'wan'
        option ifname 'eth0'
        option proto 'dhcp'

config interface 'wan6'
        option ifname 'eth0'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '1 2 3 4 0t'

config interface 'wwan'
        option proto 'dhcp'

root@Bucatarie-RPT:~# cat /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option hwmode '11g'
        option path 'platform/qca956x_wmac'
        option channel 'auto'
        option txpower '20'
        option htmode 'HT20'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'Andrei'
        option encryption 'psk2'
        option key 'password'
        option ieee80211r '1'
        option ft_over_ds '0'
        option ft_psk_generate_local '1'
        option disassoc_low_ack '0'
        option skip_inactivity_poll '1'
        option mobility_domain '6C78'

config wifi-iface 'wifinet1'
        option device 'radio0'
        option mode 'sta'
        option ssid 'Andrei'
        option bssid 'E4:C3:2A:86:BA:03'
        option key 'password'
        option wds '1'
        option encryption 'psk2'
        option network 'lan'
        option skip_inactivity_poll '1'
        option disassoc_low_ack '0'

I can also get logs from the Kali machine if needed.

remove the STP option from below:

A tunnel isn't usually a dhcp client. It should probably be proto 'none':

Remove all of the 802.11r related items (basically everything after the key line), as 802.11r tends to cause more problems than it solves... do this on all your devices:

This device is really old and the firmware on it (19.07) is long since EOL and unsupported. This should probably be retired and upgraded ASAP.

remove stp and igmp snooping:

and of course, remove 802.11r.

1 Like

Do I need to reboot after modifying these options?

Yes. It is best to reboot to make sure everything reloads properly.

Still doesn't work. I can't disable 802.11r since my phone doesn't even connect to the WR940N without it. I've tried switching to FT over DS without success.

This suggests you have more significant overall issues with your wifi configurations and AP tuning.

802.11r does not determine if a device will or will not connect to a given AP... more than likely, the phone is not connecting to the 940N because it is trying to connect to (or maintain a connection with) another AP.

I suspect that the power levels and channels are not properly optimized... this is the first step that should be done. I like this video for describing the process -- it talks about Unifi, but the concepts apply to all wifi as long as the controls are exposed (and they are in OpenWrt).

more than likely, the phone is not connecting to the 940N because it is trying to connect to (or maintain a connection with) another AP.

It is connecting to it, then disconnecting, then connecting to the other AP, then disconnecting and the cycle repeats. Here's a video where you can see it better: https://imgur.com/a/mgr6ZZ2
I don't want to force it to connect to the 940n in particular, I just want it to connect and stay connected to the strongest signal (the Archer A6 in the video, starting with E4:C3)

does it stay connected, if you'd create a separate SSID for it, to connect to ?

This problem doesen't seem to happen when there is only one AP. It starts the disconnect-reconnect cycle after roaming from one AP to another, like it can't decide what AP it should stay on. It's really annoying.

Have you gone through the process of manually setting channels and adjusting (decreasing) the power levels on each AP as I recommended earlier? This is absolutely critical for roaming to work properly.

Also, roaming is a client side process -- they have logic that looks at a number of factors in deciding to stick with a given connection or to roam to the next. So what you want to do is setup the conditions such that the client devices can make good decisions (and also, not all devices have good roaming algorithms... some are better than others).

Have you tried forgetting both APs and reconnecting to the most used one, see if it flakes out, then add the least used again?

TL;DR: Firewall rules can factor into wifi client death/re-auth patterns.

A few weeks ago I had a maddening problem where 1 specific wifi client device -- an air quality monitor, in this case -- kept being disconnected "due to inactivity" on my 802.11b/g IOT network.

After going through many, many other troubleshooting attempts, including turning off all other wifi clients and networks not in use, many iterations of config changes to wifi network parameters (beacon intervals, fast roaming, etc.) multiple total network resets, eventually even setting up Wireshark & tcpdump to sniff packets to try to find some obscure bug --

What it turned out to be was misconfigured firewall rules.

I had a couple FW rules set up to restrict this device's access to just a couple of hosts on the internet. But the device wanted access to other internet hosts, and after failing to reach them after a certain number of tries (due to my firewall rules,) the device itself would disconnect from/reconnect to wifi in an attempt to obtain access to the host(s) it wanted to talk to.

Once I reconfigured the FW rules to allow this wifi client access to all of the internet destinations it wanted to reach, the "deauth due to inactivity" errors stopped.

1 Like

They both have the same name so I can't connect to one in particular.

I don't have any firewall rules for this device.