# wpa_supplicant Attempts to connect many times.

## luizm929

After an upgrade about a 2 months ago wpa stopped connecting right away. Sometimes it connects right away and sometimes it takes 2 hours to make a successful connection using WPA2 personal encryption. 

Any help is appreciated. 

Compile flags for wpa_supplicant

```

[ebuild   R    ] net-wireless/wpa_supplicant-2.4-r3::gentoo  USE="dbus qt4 readline ssl -ap -eap-sim -fasteap -gnutls -hs2-0 -p2p (-ps3) (-selinux) -smartcard -tdls -uncommon-eap-types -wimax -wps" 0 KiB

```

This is my wpa_supplicant.conf

```

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

update_config=1

network={

        ssid="edo"

        psk="0000000000000000000000"    # this is not the real key just typed zeroes to show that my key is 22 char long

        proto=RSN

        key_mgmt=WPA-PSK

        pairwise=CCMP

        auth_alg=OPEN

}

network={

        ssid="Google Starbucks"

        key_mgmt=NONE

        auth_alg=OPEN

}

```

uname -a spits out

```

Linux Brasidas 3.14.35-rt32-rc1 #8 SMP PREEMPT RT Tue Jul 7 22:41:37 Local time zone must be set i686 Intel(R) Core(TM)2 Duo CPU L7500 @ 1.60GHz GenuineIntel GNU/Linux

```

Output of #dmesg 

```

[ 1137.922130] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 1138.123095] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 1138.324092] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 1138.525082] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 1261.209501] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 1261.209562] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 1261.410108] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 1261.611109] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 1261.812101] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 1385.213751] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 1385.213812] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 1385.414097] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 1385.615089] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 1385.816104] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 1510.037051] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 1510.037114] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 1510.238093] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 1510.439103] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 1510.640105] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 1635.065372] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 1635.065433] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 1635.266093] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 1635.467084] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 1635.668076] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 1759.991198] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 1759.991236] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 1760.192089] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 1760.393085] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 1760.594083] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 1884.814600] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 1884.814664] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 1885.015079] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 1885.216088] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 1885.417075] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 2009.125979] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 2009.126144] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 2009.327055] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 2009.528085] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 2009.729083] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 2133.539812] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 2133.539874] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 1/3)

[ 2133.740107] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 2/3)

[ 2133.941101] wlp3s0: direct probe to c0:c1:c0:89:39:86 (try 3/3)

[ 2134.142097] wlp3s0: authentication with c0:c1:c0:89:39:86 timed out

[ 2258.568008] wlp3s0: authenticate with c0:c1:c0:89:39:86

[ 2258.568128] wlp3s0: send auth to c0:c1:c0:89:39:86 (try 1/3)

[ 2258.616919] wlp3s0: authenticated

[ 2258.618064] wlp3s0: associate with c0:c1:c0:89:39:86 (try 1/3)

[ 2258.622051] wlp3s0: RX AssocResp from c0:c1:c0:89:39:86 (capab=0x411 status=0 aid=3)

[ 2258.649405] wlp3s0: associated

[ 2258.649459] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready

```

----------

## charles17

You could do # killall wpa_supplicant and start in debug mode: 

https://wiki.gentoo.org/wiki/Wpa_supplicant#Run_wpa_supplicant_in_debug_mode

Replace -iwlan0 with your interface name.

----------

## mir3x

Router just doesnt answer mostly

1) Try moving router closer, see if it helps 

2) Downgrade kernel  or linux-firmware to version from 2 months ago, if it helps google for your_network_card regressions in kernel or some fix.

If downgarding linux-firmware helped then stick for that version for some time and watch for new versions.

Or maybe someone else is using your network very hard for last 2 months  :Very Happy:  ( eg. your neighbour who is closer and brutefoced wps or something like that )

----------

## szatox

I have noticed exactly the same issue myself, using 2 different wifis (ath5k and ath9k). Never had time to get to fixing it so far, partialy because wifi around was a bit unstable, and partially thanks to gsm modem, but running hostapd on one wifi and wpa_supplicant on the other (both in the back of the same box) and not being able to associate makes me think it's not a problem with signal strength.

So, luizm, no idea if it makes you feel better, but you're not alone.

----------

## luizm929

Charles17, thanks for your response. I was about to enable debug mode but I think its fixed. 

mir3x: the strange thing is that it used to work with this firmare and kernel verison. 

szatox: I think I fixed it but I am not sure. It now connects automatically like before (pretty fast). 

This was my /etc/conf.d/net file

```

modules_wlan0="wpa_supplicant"

wpa_supplicant_wlan0="-Dwext"

config_wlan0="dhcp"

ifplugd_wlp3s0="--api-mode=wlan"

```

But then I changed it to.

```

modules_wlan0="wpa_supplicant"

#wpa_supplicant_wlan0="-Dn180211"     

config_wlan0="dhcp"

#ifplugd_wlp3s0="--api-mode=wlan"

```

It may have been luck that the last 5 times it connected right after login into my system, not sure. 

I also forgot to mention that on a public wifi it would connect automatically, it only gave me problems when trying to connect to a network with WPA2. 

I kept my wpa_supplicant.conf file the same. 

I will let you know guys if, this modification fixed the problem

----------

## luizm929

It was just luck that the WIFI  started connecting right away. 

Things  tried. 

Downgrading firmware to every possible version.

Recompiling wpa_supplicant.

This is the log I got from enabling logging capabilities on wpa_supplicant.

[url]

http://pastebin.com/ZL2GLcRE

[/url]

Dont know what else to do.

----------

## charles17

 *luizm929 wrote:*   

> Dont know what else to do.

 

Remove the (manually created?) network= sections from wpa_supplicant.conf and use wpa_gui or wpa_cli for connetcting again.

----------

## mir3x

I googled that:

```
nl80211: Drv Event 37 (NL80211_CMD_AUTHENTICATE) received for wlp3s0

nl80211: MLME event 37; timeout with XXXXX
```

and it looks like its drivers fault, and using compat-wireless might help

List of those drivers is there:

https://wireless.wiki.kernel.org/en/users/Drivers

There was package compat-wireless / compat-drivers in gentoo but it seems too old. Maybe try getting it from that site ?

https://www.kernel.org/pub/linux/kernel/projects/backports/stable/

Or maybe try newer kernel ?

Or i noticed that

```
wlp3s0: External program started a scan

```

maybe its NetworkManager ??? IF u have it started then: rc-update del NetworkManager

NM usually messes with wpa_supplicant.

btw why u use arch i686 instead x86_64 on that core 2 duo?

----------

## szatox

I thought it could be kernel so I tested it. It's all the same with 3.18.7 (which used to work), 3.18.12 (also used to work) and 4.0.5 (just upgraded)

Must be user-land.

And I'm using wpa_supplicant from within netifrc here.

Since I have atheros and aircrack, I used this stuff to setup a second interface in monitor mode and track the traffic while wpa_supplicant attempts to connect to my hostapd. It can see beacons, probes, basicaly everything looks fine but it still can't connect:

Jul 14 20:08:10 [avahi-daemon] Registering new address record for fe80::XXX on wlan0.*.

Jul 14 20:08:10 [kernel] wlan1: authenticate with XXX

Jul 14 20:08:10 [kernel] wlan1: direct probe to XXX (try 1/3)

Jul 14 20:08:11 [kernel] wlan1: direct probe to XXX (try 2/3)

Jul 14 20:08:11 [kernel] wlan1: direct probe to XXX (try 3/3)

Jul 14 20:08:11 [kernel] wlan1: authentication with XXX timed out

Jul 14 20:08:12 [kernel] wlan1: authenticate with XXX 

Jul 14 20:08:12 [kernel] wlan1: direct probe to XXX (try 1/3)

Jul 14 20:08:12 [kernel] wlan1: direct probe to XXX (try 2/3)

Jul 14 20:08:12 [kernel] wlan1: direct probe to XXX (try 3/3)

Jul 14 20:08:13 [kernel] wlan1: authentication with XXX timed out

And I know it's not because of hostapd. My other machines don't complain. One is windows, the other is outdated thoguh. 

Looks a bit like wpa_supplicant hasn't recognized accepts which must had been sent.

For sake of completness, my wpa_supplicant is

 *Quote:*   

> [ebuild   R    ] net-wireless/wpa_supplicant-2.4-r3::gentoo  USE="dbus hs2-0 qt4 readline ssl -ap -eap-sim -fasteap -gnutls -p2p (-ps3) (-selinux) -smartcard -tdls -uncommon-eap-types -wimax -wps" 0 KiB

 

Anyone can share working one?

----------

## mir3x

Its definitely drivers fault, write what driver is in use ( maybe it based carl9170 - which doesn't work on n band correctly ?, I had it, damn crap  :Very Happy:  ). Google for that atheros , and u will find answer.

And u should check those drivers on https://backports.wiki.kernel.org/

You might try change to g band in router and change cipher maybe but I doubt it help ( unless its that carl1970)

----------

## szatox

It definitely is not driver, neither in my case nor luizm's. This stuff used to work and good modules don't just get tired/bored/offended and slam the door.

And it's not wpa_supplicant.conf issue either. Hardware is more likely to "just break", but I can't really imagine 2 wifis breaking down without any common factor, and something like that would fry mobo too.

Older version of wpa_supplicant has just been removed from portage. Now, that's a failure, can't downgrade and test again anymore. 

Gotta get closer look at debug mode. Any other ideas what could it be (or how to look for it)?

A line from qlop -l:

Mon May 18 21:30:37 2015 >>> net-wireless/wpa_supplicant-2.4-r3 # too long ago

Fri Jul  3 22:55:53 2015 >>> net-wireless/wireless-regdb-20150605 # possible? 

Fri Jul  3 23:43:27 2015 >>> net-libs/libpcap-1.7.4 # maybe this?

----------

## mir3x

According to http://gpo.zugaina.org/net-wireless/wpa_supplicant

there is 2.3 version in maggu2810-overlay.

```
Fri Jul 3 22:55:53 2015 >>> net-wireless/wireless-regdb-20150605 # possible?
```

I doubt, that's some database for countries and max transmit power for each one, and allowed channel ( but maybe something more ? )

```
Fri Jul 3 23:43:27 2015 >>> net-libs/libpcap-1.7.4 # maybe this?
```

Only 'ppp' depends on it ... , so no.

----------

## luizm929

mir3x: I use i686 because I use my machine for audio recording( with RT kernel), I also install soft synths and last time I tried building a system x86_64 on this dual core(couple of years ago) it gave me much trouble(things would not compile and I wasted many hours trying to install the system and tools I need without success).

I tried an ath5k  wifi card I had laying around. It did not connect just like the built in wifi card intel iwl4965. 

I also tried recompiling wpa_supplicant with  -qt4 in case the GUI was causing problems and still nothing. 

Also I tried iwl4965 as a module. nothing. 

Since I tried two card it is probably not the driver.

----------

## szatox

Thanks for that overlay, I'll try it out

In the meantime, I have noticed that I can't set regulatory domain after boot. Crda fails will a seemingly common error -7 nobody knows what to do about, both when used manually and when called from udev. Currently it can only be set during cfg80211 loading.

Also, there is something funny about -D option AKA driver wpa_supplicant uses to configure NIC. Haven't figured it out yet, making my way through debug-level logs from wpa_supplicant. Diff helps a bit with this, after sedding variables out, of course.

btw, wpa_gui doesnt have much success connecting either

----------

