AnneCreek
Posts: 35
Joined: Thu Oct 04, 2018 4:51 pm

wpa_cli gets stuck - no access to wpa_supplicant until reboot

Thu Oct 11, 2018 5:39 pm

I am test-driving wpa_cli and having a small issue.
When used In plain interactive mode "wpa_cli: , no options, it fails to connect due to wrong password.
It tries three times, that is OK, and then it gives " Could not connect to wpa_supplicant: (nil) - re-trying".

Then I have to reboot to be able to use "wpa_cli" " or raspi-config - Network setup to get rid of the "cannot access wpa_supplicant.

PS Today I did update /upgrade and wpa_cli now works flawlessly, it did not yesterday!

Code: Select all

[email protected]:/ $ sudo raspi-config
[email protected]:/ $ sudo wpa_cli
wpa_cli v2.4
Copyright (c) 2004-2015, Jouni Malinen <[email protected]> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.



Interactive mode

Could not connect to wpa_supplicant: (nil) - re-trying
^[email protected]:/ $ sudo reboot
Connection to 10.0.1.39 closed by remote host.
Connection to 10.0.1.39 closed.
[email protected]:~$ ssh [email protected]
[email protected]'s password: 
Linux pi 4.14.70-v7+ #1144 SMP Tue Sep 18 17:34:46 BST 2018 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: Thu Oct 11 15:31:40 2018 from 10.0.1.41
[email protected]:~ $ sudo wpa_cli
wpa_cli v2.4
Copyright (c) 2004-2015, Jouni Malinen <[email protected]> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.


Selected interface 'wlan0'

Interactive mode

<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SSID-REENABLED id=0 ssid="tseesee"
<3>Trying to associate with 28:cf:da:b0:30:67 (SSID='tseesee' freq=2462 MHz)
<3>Associated with 28:cf:da:b0:30:67
<3>CTRL-EVENT-DISCONNECTED bssid=28:cf:da:b0:30:67 reason=0
<3>WPA: 4-Way Handshake failed - pre-shared key may be incorrect
<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="tseesee" auth_failures=2 duration=20 reason=WRONG_KEY
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SSID-REENABLED id=0 ssid="tseesee"
<3>Trying to associate with 28:cf:da:b0:30:67 (SSID='tseesee' freq=2462 MHz)
<3>Associated with 28:cf:da:b0:30:67
<3>CTRL-EVENT-DISCONNECTED bssid=28:cf:da:b0:30:67 reason=0
<3>WPA: 4-Way Handshake failed - pre-shared key may be incorrect
<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="tseesee" auth_failures=3 duration=30 reason=WRONG_KEY
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-TERMINATING 
Connection to wpa_supplicant lost - trying to reconnect
Connection to wpa_supplicant re-established
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SSID-REENABLED id=0 ssid="tseesee"
<3>Trying to associate with 28:cf:da:b0:30:67 (SSID='tseesee' freq=2462 MHz)
<3>Associated with 28:cf:da:b0:30:67
<3>CTRL-EVENT-DISCONNECTED bssid=28:cf:da:b0:30:67 reason=0
<3>WPA: 4-Way Handshake failed - pre-shared key may be incorrect
<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="tseesee" auth_failures=2 duration=20 reason=WRONG_KEY
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SSID-REENABLED id=0 ssid="tseesee"
<3>Trying to associate with 28:cf:da:b0:30:67 (SSID='tseesee' freq=2462 MHz)
<3>Associated with 28:cf:da:b0:30:67
<3>CTRL-EVENT-DISCONNECTED bssid=28:cf:da:b0:30:67 reason=0
<3>WPA: 4-Way Handshake failed - pre-shared key may be incorrect
<3>CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="tseesee" auth_failures=3 duration=30 reason=WRONG_KEY
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-FAILED ret=-1 retry=1
<3>CTRL-EVENT-TERMINATING 
Connection to wpa_supplicant lost - trying to reconnect
> quit
[email protected]:~ $ sudo wpa_cli
wpa_cli v2.4
Copyright (c) 2004-2015, Jouni Malinen <[email protected]> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.



Interactive mode

Could not connect to wpa_supplicant: (nil) - re-trying




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

Re: wpa_cli gets stuck - no access to wpa_supplicant until reboot

Fri Oct 12, 2018 8:14 am

There must be a wpa_supplicant process running for wpa_cli to connect to.
You can control-C the wpa_cli process if it hangs.

Usually wpa_supplicant is started when a wifi interface is set up. The wpa_supplicant process is stopped when the interface is set down.

You can also start wpa_supplicant in standalone ("master") mode, at which time using wpa_cli you could "interface_add wlan0 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf" and then start configuring an IP address on wlan0.
In master mode, wpa_cli never hangs because wpa_supplicant always runs. It lives independently of the interfaces state.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

AnneCreek
Posts: 35
Joined: Thu Oct 04, 2018 4:51 pm

Re: wpa_cli gets stuck - no access to wpa_supplicant until reboot

Fri Oct 12, 2018 4:46 pm

OK, I did the following. Attached bellow.

So what does this line telling me ?
"Successfully initialized wpa_supplicant"

And starting "wpa_clI' gives
"Could not connect to wpa_supplicant: (nil) - re-trying"

and it just keeps on "re-trying" .



Code: Select all

[email protected]:~ $ sudo wpa_supplicant
Successfully initialized wpa_supplicant
wpa_supplicant v2.4
Copyright (c) 2003-2015, Jouni Malinen <[email protected]> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)

usage:
  wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] [-g<global ctrl>] \
        [-G<group>] \
        -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
        [-b<br_ifname>] [-e<entropy file>] [-f<debug file>] \
        [-o<override driver>] [-O<override ctrl>] \
        [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
        [-m<P2P Device config file>] \
        [-p<driver_param>] [-b<br_ifname>] [-I<config file>] ...]

drivers:
  nl80211 = Linux nl80211/cfg80211
  wext = Linux wireless extensions (generic)
  wired = Wired Ethernet driver
  none = no driver (RADIUS server/WPS ER)
options:
  -b = optional bridge interface name
  -B = run daemon in the background
  -c = Configuration file
  -C = ctrl_interface parameter (only used if -c is not)
  -i = interface name
  -I = additional configuration file
  -d = increase debugging verbosity (-dd even more)
  -D = driver name (can be multiple drivers: nl80211,wext)
  -e = entropy file
  -f = log output to debug file instead of stdout
  -g = global ctrl_interface
  -G = global ctrl_interface group
  -K = include keys (passwords, etc.) in debug output
  -s = log output to syslog instead of stdout
  -T = record to Linux tracing in addition to logging
       (records all messages regardless of debug verbosity)
  -t = include timestamp in debug messages
  -h = show this help text
  -L = show license (BSD)
  -o = override driver parameter for new interfaces
  -O = override ctrl_interface parameter for new interfaces
  -p = driver parameters
  -P = PID file
  -q = decrease debugging verbosity (-qq even less)
  -u = enable DBus control interface
  -v = show version
  -W = wait for a control interface monitor before starting
  -m = Configuration file for the P2P Device interface
  -N = start describing new interface
example:
  wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
[email protected]:~ $ sudo wpa_cli
wpa_cli v2.4
Copyright (c) 2004-2015, Jouni Malinen <[email protected]> and contributors

This software may be distributed under the terms of the BSD license.
See README for more details.



Interactive mode

Could not connect to wpa_supplicant: (nil) - re-trying



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

Re: wpa_cli gets stuck - no access to wpa_supplicant until reboot

Fri Oct 12, 2018 4:50 pm

Please, try "man wpa_supplicant" and read the docs at https://w1.fi if you want authoritative information.

(Maybe option -g could help)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

AnneCreek
Posts: 35
Joined: Thu Oct 04, 2018 4:51 pm

Re: wpa_cli gets stuck - no access to wpa_supplicant until reboot

Sat Oct 13, 2018 4:38 am

epoch1970 wrote:
Fri Oct 12, 2018 4:50 pm
Please, try "man wpa_supplicant" and read the docs at https://w1.fi if you want authoritative information.

(Maybe option -g could help)
Why do I have to (bother) to use wpa_supplicant if wpa_cli is "front end" for it?
Not being smart a.. but applying similar logic - I should not use wpa_gui as " replacement" for wpa_cli either.

"man" are nice, but is it not the purpose of this forum to help each other?

BTW - how does this option -g help me to use wpa_cli without rebooting? ?

-g global ctrl_interface
Path to global ctrl_interface socket. If specified, interface definitions may be omitted.

User avatar
DougieLawson
Posts: 34160
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: wpa_cli gets stuck - no access to wpa_supplicant until reboot

Sat Oct 13, 2018 7:43 am

AnneCreek wrote:
Sat Oct 13, 2018 4:38 am
epoch1970 wrote:
Fri Oct 12, 2018 4:50 pm
Please, try "man wpa_supplicant" and read the docs at https://w1.fi if you want authoritative information.

(Maybe option -g could help)
Why do I have to (bother) to use wpa_supplicant if wpa_cli is "front end" for it?
Not being smart a.. but applying similar logic - I should not use wpa_gui as " replacement" for wpa_cli either.

"man" are nice, but is it not the purpose of this forum to help each other?

BTW - how does this option -g help me to use wpa_cli without rebooting? ?

-g global ctrl_interface
Path to global ctrl_interface socket. If specified, interface definitions may be omitted.
Why do all of your posts appear to be confrontational. Lighten up, you're getting free advice.

If wpa_cli doesn't work, try killing and restarting wpa_supplicant then restarting your wpa_cli session.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

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

Re: wpa_cli gets stuck - no access to wpa_supplicant until reboot

Sat Oct 13, 2018 1:19 pm

The "do as I want" injunction doesn't work too well here I think. Not with me at least, so this is my last reply to you, AnneCreek.

More importantly, that attitude is proven not to work at all with machines and programs.
You obviously want something out of your machine, you'll have to learn how to tell it what it is you want.

One last time. Life cycles of wpa_supplicant and wpa_cli:
- wpa_supplicant is the backend, wpa_cli is the front-end. wpa_cli needs a running wpa_supplicant to connect to.
- By default, wpa_supplicant runs only as long as the wifi interface it manages is active. Then it stops.
- Unless you start it in stand-alone, "master mode", with -g. It will stay running forever regardless of interfaces states...
- ...at which time you can use wpa_cli, with the same -g option, to connect to it and configure it.

When you reboot you're just resetting the wifi interface to its normal up state, wpa_supplicant is running and so wpa_cli "magically" works again...

I know that because I've read it. You can too, I've told you where. Good luck.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

AnneCreek
Posts: 35
Joined: Thu Oct 04, 2018 4:51 pm

Re: wpa_cli gets stuck - no access to wpa_supplicant until reboot

Sat Oct 13, 2018 2:30 pm

It looks as folks here are confusing facts with fiction.

If something does not work as advertised there is no other way to describe it as a failure. I am not asking for miracles, I just want to make it work and understand why it does or does not.


"When you reboot you're just resetting the wifi interface to its normal up state, wpa_supplicant is running and so wpa_cli "magically" works again... "

This is contradictory what you just said - "start wpa_supplicant".

It it ether running or not after reboot.

If you look at "raspi-config" code , as I did, there is no "start wpa_supplicant" code , only "wpa_cli" commands.

If you do "wpa_cli" it comes up with "wpa_supplicant" initialized.

Return to “Networking and servers”