Wpa_supplicant issue - "Authentication request to the driver failed"

I am currently using OpenWrt 18.06 on a MT7620a chipset with a Ralink RT2800 wireless chip in it. I am running a custom daemon that manages an AP interface as well as a Station interface to allow a mobile app to connect to it and pass wifi credentials. In the perfect flow, the mobile app will connect to the AP interface, pass the credentials, and then the daemon uses wpa_supplicant to attempt to connect the station interface to the wireless network provided by the mobile app.

When connecting to any network via the standard OpenWrt method, i.e. create an interface in /etc/config/wireless and put the credentials in there as well, there is no issue connecting to any network. However, when the daemon attemps to use wpa_supplicant to connect to the network, most of the time wpa_supplicant gives the following error:

Tue Jul 16 00:49[   48.426019] apcli0: authenticate with 7e:d2:94:35:88:d1
:55 2019 daemon.notice wpa_supplicant[1643]: apcli0: SME: Trying to authenticate with 7e:d2:94:35:88:d1 (SSID='Scranton5' freq=2452 MHz)
Tue Jul 16 00:49:55 2019 daemon.notice wpa_supplicant[1643]: apcli0: SME: Authentication request to the driver failed
Tue Jul 16 00:49:55 2019 daemon.notice wpa_supplicant[1643]: apcli0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="Scranton5" auth_failures=1 duration=10 reason=CONN_FAILED

This error occurs most of the time, but sometimes the connection succeeds. What would be causing this error?

Thanks in advance

Have you compared the parameters that you pass to wpa_supplicant with the parameters that UCI passes?

the commands we send are like this:

2019-07-16T20:43:56.755 [DBG] cond::wifi_platform_req()  sending: REMOVE_NETWORK all
2019-07-16T20:43:56.756 [DBG] cond::wifi_platform_req()  msg: OK

2019-07-16T20:43:56.756 [DBG] cond::wifi_platform_req()  sending: ADD_NETWORK
2019-07-16T20:43:56.758 [DBG] cond::wifi_platform_req()  msg: 0

2019-07-16T20:43:56.758 [DBG] cond::wifi_platform_req()  sending: SET_NETWORK 0 ssid 536372616e746f6e35
2019-07-16T20:43:56.760 [DBG] cond::wifi_platform_req()  msg: OK

2019-07-16T20:43:56.760 [DBG] cond::wifi_platform_req()  sending: SET_NETWORK 0 bssid 7e:d2:94:35:88:d1
2019-07-16T20:43:56.761 [DBG] cond::wifi_platform_req()  msg: OK

2019-07-16T20:43:56.762 [DBG] cond::wifi_platform_req()  sending: SET_NETWORK 0 key_mgmt WPA-PSK
2019-07-16T20:43:56.763 [DBG] cond::wifi_platform_req()  msg: OK

2019-07-16T20:43:56.763 [DBG] cond::wifi_platform_req()  sending: SET_NETWORK 0 psk "MY_PASSWORD!"
2019-07-16T20:43:57.306 [DBG] cond:wifi_platform_req()  msg: OK

This usually results in the "Authentication request to the driver failed" error. However, when I do the same thing but instead putting that info into wpa_supplicant.conf like this, it works:

network={
        ssid=536372616e746f6e35
        bssid=7e:d2:94:35:88:d1
        key_mgmt=WPA-PSK
        psk="MY_PASSWORD!"
}

UPDATE: This issue seems to come from the fact that I have a simultaneous AP interface and a Station interface. It seems like this should be doable, but isn't working even when I try to send the wifi connect commands manually to wpa_supplicant when both interfaces are are up. Does anyone know of a way to make this work? I am using the nl80211 driver.

I am currently dealing with a similar issue...

The problem appears to be that you (we) are trying to switch channels.

Still working on this, will see if theres a way to have wpa notify hostapd of the channel change. Or maybe this is not the issue... But it looks like it probably is...

I have same issue on WR-1043nd v3.

@mikhelms I Have tplink wr-1043nd (AP+STA), when main router switch channel, I got issue same as above.
And I have solution for it: Create service script listener when detect failure -> turn off and turn on wireless -> connect successful:
script: /usr/bin/fix_sta.sh

#!/bin/sh
#
 
while [ 1 ]; do  
	if [ $(iwinfo | grep -c "ESSID: unknown") -ge 1 ]; then
		echo "detected disconnect STA"
	    wifi down
	    sleep 5
	    wifi up
	fi
	sleep 60
done

service: /etc/init.d/fixstaservice

#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=01
start_service() {
    procd_open_instance
    procd_set_param command /bin/sh "/usr/bin/fix_sta.sh"
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}

refer: https://openwrt.org/docs/guide-developer/procd-init-script-example