Wifi not connect when boot but connect after reboot


#1

Hi,

I’m in front of a weird issue.

When i boot the pi, i’ve to manually connect to the wifi from GUI.

But the strange thing is if i reboot the pi, the wifi connects automatically, even if it’s not connected before reboot.

On the log during the first boot i’ve got :

mars 10 09:51:05 osmc wpa_supplicant[387]: WPS: Converting push_button to virtual_push_button for WPS 2.0 compliance
mars 10 09:51:05 osmc connmand[249]: Skipping disconnect of 4c697665626f782d38383837_managed_psk, network is connecting.
mars 10 09:51:05 osmc connmand[249]: ipconfig state 2 ipconfig method 1
mars 10 09:51:05 osmc wpa_supplicant[387]: wlan0: Trying to associate with 30:7c:b2:30:88:87 (SSID='Livebox-8887' freq=2462 MHz)
mars 10 09:51:05 osmc connmand[249]: ipconfig state 2 ipconfig method 1
mars 10 09:51:06 osmc wpa_supplicant[387]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
mars 10 09:51:06 osmc connmand[249]: ipconfig state 7 ipconfig method 1
mars 10 09:51:06 osmc connmand[249]: Skipping disconnect of 4c697665626f782d38383837_managed_psk, network is connecting.
mars 10 09:51:06 osmc connmand[249]: ipconfig state 7 ipconfig method 1

I suppose this is an issue due to wpa_supplicant, or maybe after a first try my router is handling something, and make it work during the second try (e.g after reboot).

Any idea what’s going on ?

Thanks


#2

It may be one of these issues, or it may be something entirely different.
What you dont state if the make/model of your wifi dongle and your power supply.

On first boot the Raspberry Pi draws a lot current then when its finished loading. Some PSU’s dont make their rated spec. It may be down to inadequate power supply current, as when you reboot (not cold boot) the load current will not be
as extreme.

Second youre on channel 11.

Every router uses channel 1, 6 or 11 by default and this may not be the best channel. You dont say how far your router and rasbperry pi are apart so if its
not the same room try changing wifi channel in your router. In any case I’d SSH
into your RPi and ping your router:

ping -c4 192.168.1.1

Repace 192.168.1.1 with your router gateway. You need to make sure that all
packets have return values less than 3ms else the channel is too congested.
A bad channel and weak power supply could be the reason for this.
You may get other forum advice.


#3

We’d need logs of a cold boot to see what’s happening. Otherwise it’s all just speculation.

Preferably full logs: grab-logs -A


#4

Thank you for your answers.

I changed the canal of my router, i obtain better times but the wifi still doesn’t connect during a cold boot.

The logs : https://paste.osmc.tv/omelumomud

Maybe there’s a way to automatically attempt to connect after the boot process ?

Thank you.


#5

Orange Liveboxes and Funboxes have been problematic in the past.

Did this problem first appear after the latest update? If so, it might be a problem either with the new firmware or with the new kernel version.

I would also suggest that you reboot the router and see if the problem still occurs.


#6

Effectively, this problem appeared approximately 1 month ago, before everything was ok.

I rebooted the router without effect on this issue.

Thank you.


#7

One month ago predates the 4.14 kernel and latest firmware update.

Perhaps @sam_nazarko can indicate whether the previous update also included a firmware update for the Pi 2/3.

We can try to debug the WiFi connection, though I can’t guarantee that I’ll understand everything. :wink: Please edit file /lib/systemd/system/wpa_supplicant.service (using sudo) and change the line

ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

to

ExecStart=/sbin/wpa_supplicant -d -u -s -O /run/wpa_supplicant

ie you’re adding a -d debug option. Then perform a cold boot, wait a minute and connect again via the Kodi interface.

Finally, run sudo journalctl -t wpa_supplicant | paste-log and let us know the URL.


#8

Here it is : https://paste.osmc.tv/egepalowaq

Thank you !! :slight_smile:


#9

When your Pi tries to associate with the Livebox, the connection is rejected with a result code of 16:

mars 13 13:01:59 osmc wpa_supplicant[428]: nl80211: Drv Event 46 (NL80211_CMD_CONNECT) received for wlan0
mars 13 13:01:59 osmc wpa_supplicant[428]: nl80211: Connect event (status=16 ignore_next_local_disconnect=0)
mars 13 13:01:59 osmc wpa_supplicant[428]: wlan0: Event ASSOC_REJECT (13) received
mars 13 13:01:59 osmc wpa_supplicant[428]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
mars 13 13:01:59 osmc wpa_supplicant[428]: wlan0: Radio work 'connect'@0x1d8d9e8 done in 0.358285 seconds
mars 13 13:01:59 osmc wpa_supplicant[428]: Added BSSID 30:7c:b2:30:88:87 into blacklist

Because the Livebox rejected the association, wpa_supplicant places the Livebox’s MAC address on a blacklist. According to this:

This blacklist is used to force wpa_supplicant to go through all available BSSes before retrying to associate with an BSS that rejected or timed out association. It does not prevent the listed BSS from being used; it only changes the order in which they are tried.

though it seems not to retry automatically, according to the log.

Result code 16 means

Authentication rejected due to a timeout waiting for next frame in sequence.

When you manually try to associate with the Livebox, the blacklist is ignored and the association succeeds:

mars 13 13:02:40 osmc wpa_supplicant[428]: nl80211: Drv Event 46 (NL80211_CMD_CONNECT) received for wlan0
mars 13 13:02:40 osmc wpa_supplicant[428]: nl80211: Connect event (status=0 ignore_next_local_disconnect=0)
mars 13 13:02:40 osmc wpa_supplicant[428]: nl80211: Associated on 2447 MHz
mars 13 13:02:40 osmc wpa_supplicant[428]: nl80211: Associated with 30:7c:b2:30:88:87
mars 13 13:02:40 osmc wpa_supplicant[428]: nl80211: Operating frequency for the associated BSS from scan results: 2447 MHz
mars 13 13:02:40 osmc wpa_supplicant[428]: wlan0: Event ASSOC (0) received
mars 13 13:02:40 osmc wpa_supplicant[428]: wlan0: Association info event

wpa_supplicant was updated from version 2.3 to 2.4 with the upgrade from Debian jessie to stretch, so it’s probably not possible to revert to the previous version. If you haven’t recently upgraded the Livebox’s firmware, it looks like there might be some kind of incompatibility between your Livebox and wpa_supplicant v2.4.

I’ll see if I can find out more tomorrow.

You might also want to change the channel number. Using channel 8 is likely to result in poor performance because of interference from neighbouring APs.


#10

We can probably do little about either your router or wpa_supplicant.

Since this situation only occurs on a cold boot and can be easily fixed in the Kodi interface, a simple script in /etc/rc.local should be good enough.

Add these lines before exit 0 in /etc/rc.local:

/bin/sleep 10
if ! $(/sbin/ifconfig wlan0 | /bin/grep -q 'inet 192.168.1'); then 
    /usr/bin/connmanctl connect wifi_xxxxxxxxxxx_managed_psk >/dev/null 2>&1; 
fi

The sleep should allow enough time for the WiFi connection to finish. You can adjust it, as necessary. If you don’t have an IP address after the configured time, it will try to connect to the AP. Hopefully, this will work.

You should also change xxxxxxxxxxx to the correct value for your WiFi interface (connmanctl services will show you what it should be).


Auto-reconnect OSMC RaspBi to wireless
#17

It does the work, thank you very much :slight_smile: