Wifi won't auto reconnect

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
jptaranto
Posts: 3
Joined: Thu Oct 10, 2019 10:33 am

Wifi won't auto reconnect

Post by jptaranto » Thu Oct 10, 2019 10:49 am

I've attempted to troubleshoot this one by myself for some time but I haven't turned up anything.

My wifi drops out routinely as the Pi is near a microwave - I've tried changing bands and what not, but it seems the drop outs are something I need to deal with. This - until now - hasn't been a problem as the dietpi-wifi-monitor script always reconnected without issue.

After updating my Pi to the latest version of DietPi, the wifi auto reconnect script has stopped working and I can't figure out why.

I'm using a Edimax USB adapter as so:

Code: Select all

[email protected]:~$ lsusb
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
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
The script is running fine:

Code: Select all

[email protected]:~$ service dietpi-wifi-monitor status
● dietpi-wifi-monitor.service - DietPi-WiFi-Monitor
   Loaded: loaded (/etc/systemd/system/dietpi-wifi-monitor.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-10-10 20:05:49 AEDT; 32min ago
  Process: 764 ExecStartPre=/bin/dash -c [ -e /sys/class/net/wlan$(sed -n 2p /DietPi/dietpi/.network) ] (code=exited, status=0/SUCCESS)
  Process: 751 ExecStartPre=/DietPi/dietpi/func/obtain_network_details (code=exited, status=0/SUCCESS)
 Main PID: 769 (dietpi-wifi-mon)
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/dietpi-wifi-monitor.service
           ├─ 769 /bin/bash /var/lib/dietpi/services/dietpi-wifi-monitor.sh
           └─2351 sleep 10

Oct 10 20:05:49 KitchenPi systemd[1]: Starting DietPi-WiFi-Monitor...
Oct 10 20:05:49 KitchenPi systemd[1]: Started DietPi-WiFi-Monitor.
Oct 10 20:05:49 KitchenPi dietpi-wifi-monitor.sh[769]: Checking connnection for: wlan0 via ping to default gateway every 10 seconds
And the connection works fine when the Pi first boots:

Code: Select all

[email protected]:~$ iwconfig
eth0      no wireless extensions.

lo        no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"Black Cockatoo"  Nickname:"<[email protected]>"
          Mode:Managed  Frequency:2.437 GHz  Access Point: F0:9F:C2:FD:8B:24   
          Bit Rate:72.2 Mb/s   Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=100/100  Signal level=82/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
I've enabled logging and once the connection drops there are endless lines related to it trying to reconnect:

Code: Select all

wpa_supplicant[6518]: wlan0: Trying to associate with f0:9f:c2:fd:8b:24 (SSID='Black Cockatoo' freq=2437 MHz)
Oct 10 01:25:26 KitchenPi wpa_supplicant[6518]: wlan0: Association request to the driver failed
Oct 10 01:25:27 KitchenPi dhclient[6547]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
Oct 10 01:25:32 KitchenPi dietpi-wifi-monitor.sh[775]: Detected connection loss: wlan0. Reconnecting...
Oct 10 01:25:32 KitchenPi dhclient[6613]: Killed old client process
Oct 10 01:25:32 KitchenPi dietpi-wifi-monitor.sh[775]: Killed old client process
Oct 10 01:25:33 KitchenPi dhclient[6613]: Internet Systems Consortium DHCP Client 4.3.5
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: Internet Systems Consortium DHCP Client 4.3.5
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: Copyright 2004-2016 Internet Systems Consortium.
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: All rights reserved.
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: For info, please visit https://www.isc.org/software/dhcp/
Oct 10 01:25:33 KitchenPi dhclient[6613]: Copyright 2004-2016 Internet Systems Consortium.
Oct 10 01:25:33 KitchenPi dhclient[6613]: All rights reserved.
Oct 10 01:25:33 KitchenPi dhclient[6613]: For info, please visit https://www.isc.org/software/dhcp/
Oct 10 01:25:33 KitchenPi dhclient[6613]: 
Oct 10 01:25:33 KitchenPi dhclient[6613]: Listening on LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:33 KitchenPi dhclient[6613]: Sending on   LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: Listening on LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: Sending on   LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: Sending on   Socket/fallback
Oct 10 01:25:33 KitchenPi dhclient[6613]: Sending on   Socket/fallback
Oct 10 01:25:33 KitchenPi dhclient[6613]: DHCPRELEASE on wlan0 to 192.168.1.1 port 67
Oct 10 01:25:33 KitchenPi dhclient[6613]: send_packet: Network is unreachable
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: DHCPRELEASE on wlan0 to 192.168.1.1 port 67
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: send_packet: Network is unreachable
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: send_packet: please consult README file regarding broadcast address.
Oct 10 01:25:33 KitchenPi dietpi-wifi-monitor.sh[775]: dhclient.c:2733: Failed to send 300 byte long packet over fallback interface.
Oct 10 01:25:33 KitchenPi dhclient[6613]: send_packet: please consult README file regarding broadcast address.
Oct 10 01:25:33 KitchenPi dhclient[6613]: dhclient.c:2733: Failed to send 300 byte long packet over fallback interface.
Oct 10 01:25:34 KitchenPi wpa_supplicant[6518]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Oct 10 01:25:34 KitchenPi wpa_supplicant[6518]: wlan0: CTRL-EVENT-TERMINATING
Oct 10 01:25:35 KitchenPi wpa_supplicant[6654]: Successfully initialized wpa_supplicant
Oct 10 01:25:35 KitchenPi kernel: [380699.855570] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Oct 10 01:25:35 KitchenPi dhclient[6659]: Internet Systems Consortium DHCP Client 4.3.5
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: Internet Systems Consortium DHCP Client 4.3.5
Oct 10 01:25:35 KitchenPi dhclient[6659]: Copyright 2004-2016 Internet Systems Consortium.
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: Copyright 2004-2016 Internet Systems Consortium.
Oct 10 01:25:35 KitchenPi dhclient[6659]: All rights reserved.
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: All rights reserved.
Oct 10 01:25:35 KitchenPi dhclient[6659]: For info, please visit https://www.isc.org/software/dhcp/
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: For info, please visit https://www.isc.org/software/dhcp/
Oct 10 01:25:35 KitchenPi dhclient[6659]: 
Oct 10 01:25:35 KitchenPi dhclient[6659]: Listening on LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: Listening on LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:35 KitchenPi dhclient[6659]: Sending on   LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: Sending on   LPF/wlan0/74:da:38:ea:05:03
Oct 10 01:25:35 KitchenPi dhclient[6659]: Sending on   Socket/fallback
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: Sending on   Socket/fallback
Oct 10 01:25:35 KitchenPi dhclient[6659]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
Oct 10 01:25:35 KitchenPi dietpi-wifi-monitor.sh[775]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
Oct 10 01:25:36 KitchenPi wpa_supplicant[6655]: wlan0: Trying to associate with f0:9f:c2:fd:8b:24 (SSID='Black Cockatoo' freq=2437 MHz)
Oct 10 01:25:36 KitchenPi wpa_supplicant[6655]: wlan0: Association request to the driver failed
Oct 10 01:25:38 KitchenPi wpa_supplicant[6655]: wlan0: Trying to associate with f0:9f:c2:fd:8b:24 (SSID='Black Cockatoo' freq=2437 MHz)
Oct 10 01:25:38 KitchenPi wpa_supplicant[6655]: wlan0: Association request to the driver failed
Oct 10 01:25:40 KitchenPi wpa_supplicant[6655]: wlan0: Trying to associate with f0:9f:c2:fd:8b:24 (SSID='Black Cockatoo' freq=2437 MHz)
Oct 10 01:25:40 KitchenPi wpa_supplicant[6655]: wlan0: Association request to the driver failed
Oct 10 01:25:40 KitchenPi dhclient[6659]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
Oct 10 01:25:40 KitchenPi dietpi-wifi-monitor.sh[775]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
Oct 10 01:25:42 KitchenPi wpa_supplicant[6655]: wlan0: Trying to associate with f0:9f:c2:fd:8b:24 (SSID='Black Cockatoo' freq=2437 MHz)
Oct 10 01:25:42 KitchenPi wpa_supplicant[6655]: wlan0: Association request to the driver failed
Oct 10 01:25:46 KitchenPi dhclient[6659]: No DHCPOFFERS received.
Oct 10 01:25:46 KitchenPi dietpi-wifi-monitor.sh[775]: No DHCPOFFERS received.
Oct 10 01:25:46 KitchenPi dietpi-wifi-monitor.sh[775]: No working leases in persistent database - sleeping.
Oct 10 01:25:46 KitchenPi dhclient[6659]: No working leases in persistent database - sleeping.
Oct 10 01:25:46 KitchenPi dietpi-wifi-monitor.sh[775]: Completed
And on it goes!

Seems like there is an issue getting a new DHCP lease via the reconnect script.

If I reboot the Pi the wifi comes back on immediately.

jptaranto
Posts: 3
Joined: Thu Oct 10, 2019 10:33 am

Re: Wifi won't auto reconnect

Post by jptaranto » Thu Oct 10, 2019 10:52 am

Oh and here is my network config:

Code: Select all

[email protected]:~$ cat /etc/network/interfaces
# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Local
auto lo
iface lo inet loopback

# Ethernet
#allow-hotplug eth0
iface eth0 inet dhcp
address 0.0.0.0
netmask 0.0.0.0
gateway 0.0.0.0
#dns-nameservers 0.0.0.0

# WiFi
allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.1.44
netmask 255.255.255.0
gateway 192.168.1.1
#dns-nameservers 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

User avatar
MichaIng
Site Admin
Posts: 1728
Joined: Sat Nov 18, 2017 5:21 pm

Re: Wifi won't auto reconnect

Post by MichaIng » Wed Oct 16, 2019 6:58 pm

@jptaranto
Many thanks for your report.

We need to suppress the ifdown/ifup output it seems. This doubles with dhclient and wpa_supplicant process outputs and confuses. However yeah dhclient failes to receive an IP. Could you please try:

Code: Select all

systemctl disable --now dietpi-wifi-monitor
ifdown wlan0
sleep 10
ifup wlan0
Probably the 1 second time, we give in the script between ifdown and ifup, is not enough in your case.

What you can try as well, is to use a static IP and configure a static lease in your router? In most cases this works just well and reduces the overhead of regular DHCP leases and dhclient background process.

jptaranto
Posts: 3
Joined: Thu Oct 10, 2019 10:33 am

Re: Wifi won't auto reconnect

Post by jptaranto » Fri Oct 18, 2019 3:17 am

Thanks for the reply @MichaIng!

I've switched over to a static IP now. I'll see if that helps anything and then try the commands you posted.

Post Reply