wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Sat Dec 19, 2020 8:27 am

I have built the wifi_prov_mgr example against esp-idf v4.3-dev-2136-gb0150615d (ESP32s2)

I have changed one line to ensure that I always start provisioning.
Provisioning starts Ok, but when I use the ESP Soft Ap Provisioning App from Google Play to connect to the AP it fails with

Code: Select all

I (868) wifi_prov_mgr: Provisioning started with service name : PROV_014E3E 
I (868) app: Provisioning started
I (52168) wifi: new :<1,0>, old:<1,1>, ap:<1,1>, sta:<0,0>, prof:1
I (52168) wifi: station : 92:44:c8:a6:90:fe join, AID=1, bgn, 20
I (52288) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2
W (52708) wifi:<ba-add>idx:4 (ifx:1, 92:44:c8:a6:90:fe), tid:0, ssn:16, winSize:64
W (54378) httpd_uri: httpd_uri: URI '/' not found
W (54388) httpd_txrx: httpd_resp_send_err: 404 Not Found - This URI does not exist
E (54398) httpd_txrx: httpd_resp_send_err: error calling setsockopt : 22
Is this error from when the Android device attempts to connect to the ESP32 during provisioning?
Or is it post provisioning when the ESP32 is trying to connect to the target AP? I suspect not because there is no long indicating that the EP32 has returned STA or has finished provisioning.

The 2 warnings before the error are concerning too.

So what's going on?

Once the client connects the SoftAP to provide provisioning info, what are the endpoints it should hit up to provide that info? I'm asking because we want some control over the provisioning.

I've tried using the endpoints described here https://docs.espressif.com/projects/esp ... oning.html without much luck. Can I assume that proto-ver is a HTTP POST and the 3 others are HTTP GET?

How can I hook into the callbacks for those endpoints on the ESP32 so I can take alternate action?

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Sun Dec 20, 2020 12:57 am

OK, it looks like the example isn't failing per se.

I still get those warnings and the error, but the example continues, it's just that the UI of the SoftAp Provisioning app on Google Play didn't make it very clear what was going on.

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Sun Dec 20, 2020 1:35 am

OK, this is REALLY frustrating.
Managed to get it to send the wifi credentials once (it showed up in the logs).

But now after I provide the wifi credentials in the Android app it mainly fails with "Failed to send Wi-Fi credentials and the ESP log shows:

Code: Select all

I (811) wifi_prov_mgr: Provisioning started with service name : PROV_014E3E 
I (811) app: Provisioning started
I (15071) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<0,0>, prof:1
I (15081) wifi:station: 92:44:c8:a6:90:fe join, AID=1, bgn, 20
I (15371) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2
W (15651) wifi:<ba-add>idx:4 (ifx:1, 92:44:c8:a6:90:fe), tid:0, ssn:17, winSize:64
W (17441) httpd_uri: httpd_uri: URI '/' not found
W (17441) httpd_txrx: httpd_resp_send_err: 404 Not Found - This URI does not exist
W (40481) protocomm_httpd: Closing session as socket 57 was closed
E (40491) security1: Secure session not established
E (40491) protocomm: Decryption of response failed for endpoint prov-config
E (40501) protocomm_httpd: Data handler failed
W (40501) httpd_uri: httpd_uri: uri handler execution failed
W (40511) protocomm_httpd: Closing session as socket 57 was closed
Ideas/pointers gratefully accepted.

ESP_Shubham
Posts: 8
Joined: Mon Oct 07, 2019 6:09 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby ESP_Shubham » Mon Dec 21, 2020 1:55 pm

Hi William,

Did you modify sdkconfig while running the example?

I checked running wifi_prov_mgr example (https://github.com/espressif/esp-idf/tr ... i_prov_mgr) on specified tag, it works at my end.

Can you share sdkconfig file?

Thanks,
Shubham

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Mon Dec 21, 2020 8:51 pm

It's almost certainly a non-default sdkconfig because I am trying to resolve this within an existing project.

sdkconfig: https://gist.github.com/william-ferguso ... 7bef8ea266

Note: my main issue now is that the results are non-deterministic.
Sometimes it is able to send the wifi credentials but mostly it fails at that point.

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Wed Dec 23, 2020 12:13 am

Shubham, what are you using as the provisioning client?
I'm getting non-deterministic results and only extremely rare successes using the ESP-IDF SoftAp Provisioning Android app.

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Wed Dec 23, 2020 10:12 pm

OK, I've tested against a default SdkConfig and it still fails.

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Thu Dec 24, 2020 3:59 am

Shubham, can I just clarify that I am testing the same way as you because I seem to be seeing what looks like a race condition in the http server where it will sometimes have security configured but most often not.

Here's how I am testing:
  • ESP-IDF Android SoftAp Provisioning app
  • Click on Provision new device
  • Click on I don't have a QR code
  • Click on Connect
  • When the Wifi Assiatnt is displayed, I select the AP published by the ESP device
  • Click on the back button
  • In the Proof of Possession page enter 'abcd1234'; and click Next
  • On the Select Wifi Network page note "Failed to get WifiScan-List" Toast and empty list once the wait icon disappears.
    NB About 1 in 10 times I get the WiFi Scan list to actually return the lists of Wifi APs.
Is this how you are testing?

william.ferguson.au
Posts: 107
Joined: Wed Jan 02, 2019 8:55 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby william.ferguson.au » Fri Dec 25, 2020 12:03 am

OK, this is clearly a fault.
I have raised https://github.com/espressif/esp-idf/issues/6316 for it.

ESP_Piyush
Posts: 307
Joined: Wed Feb 20, 2019 7:02 am

Re: wifi_prov_mgr example failing with "httpd_resp_send_err: error calling setsockopt : 22"

Postby ESP_Piyush » Mon Dec 28, 2020 9:39 am

Hi William,

I have replied on the GitHub issue (https://github.com/espressif/esp-idf/is ... -751650788) and an apk with a speculative fix is also shared there

Meanwhile in the context of your earlier messages, a GET on / is not really part of the phone app's logic. This is a call that some Android phones make as soon as they connect to any network. I have seen this particularly with Xiaomi phones. Some phones also disconnect from the network if this call fails. Please check if this is happening in your case.

Regards,
Piyush

Who is online

Users browsing this forum: Google [Bot] and 72 guests