cause and cure for WIFI_REASON_ASSOC_TOOMANY?

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby mzimmers » Fri Aug 03, 2018 9:02 pm

Hi -

I'm writing an app that when on battery power, it starts wifi, connects, sends a status message, and then disconnects and stops wifi. It does this once a minute.

A few iterations in, my attempt at connecting results in a disconnect event with a reason code WIFI_REASON_ASSOC_TOOMANY. My program seems to get stuck once it's gotten this event.

- too many of what?
- what am I doing to cause this?

Additional information: I do notice that after the first iteration of this cycle, I get a lost IP message about 15 seconds after the stop. (This is fine because I restart wifi every time.) The second cycle, I get this message about 30 seconds after the stop. I'm wondering whether this has something to do with the problem I'm having, though I can't quite connect the dots on this one.
Thanks.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby kolban » Sat Aug 04, 2018 2:04 am

Although I have no idea on the underlying puzzle, I could image a couple of questions I may ask:

1. How are you disconnecting?
2. Are you waiting for a confirmation of a disconnect?
3. How are you stopping WiFi?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby mzimmers » Sun Aug 05, 2018 2:21 pm

Hi Neal -

I'm using the esp_wifi_disconnect() and esp_wifi_stop() routines. And no, I'm not waiting for confirmation of the disconnect; I'm not sure how to do that.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby kolban » Sun Aug 05, 2018 3:13 pm

Within the WiFi subsystem there is the concept of an event handler. The event handler is a function that you register which is invoked behind the scenes by the WiFi subsystem. It is typically used to inform you of WiFi lifecycle events. There are many events that can occur. Two of them might be of interest to us. The first is:

* SYSTEM_EVENT_STA_DISCONNECTED

This event is raised following a call to esp_wifi_disconnect(). We should assume that the esp_wifi_disconnect() call is an asynchronous API call. This means is that when you call it and it returns, you have NOT been disconnected .. rather you have issued a request to be eventually disconnected. You will know when you have actually been disconnected when the SYSTEM_EVENT_STA_DISCONNECTED event is received. Similarly, if you call esp_wifi_stop(), you will not have actually stopped the WiFi subsystem but merely sent a request to stop the subsystem. You should expect to receive an event of type:

* SYSTEM_EVENT_STA_STOP
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby mzimmers » Sun Aug 05, 2018 3:48 pm

Oh yes, of course...I didn't realize you were talking about the event handler. My worker tasks waits for a DISCONNECTED event before setting a local state variable. I don't wait for the STA_STOP event, but...I wouldn't think that I need to, as I only attempt a reconnect once a minute.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby mzimmers » Mon Aug 13, 2018 2:33 pm

Anyone have any ideas on this one? I need to get this fixed.

Thanks...

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby fly135 » Mon Aug 13, 2018 3:52 pm

Good luck. When using WPA2 I get a random amount of WIFI_REASON_ASSOC_FAIL errors trying to connect. Can't get an answer on that either. There is no source to look at, and no explanation of the defines.

John A

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby mzimmers » Wed Oct 10, 2018 4:31 pm

BTT. This is an ongoing problem, and I really don't know how to recover from receiving this code.

kongshui
Posts: 13
Joined: Tue May 16, 2023 11:49 am

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Postby kongshui » Thu Jun 22, 2023 4:40 am

I have encountered the same problem. In ESP-IDF V5.1

Who is online

Users browsing this forum: No registered users and 88 guests