Page 1 of 1

cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Fri Aug 03, 2018 9:02 pm
by mzimmers
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.

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Sat Aug 04, 2018 2:04 am
by kolban
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?

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Sun Aug 05, 2018 2:21 pm
by mzimmers
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.

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Sun Aug 05, 2018 3:13 pm
by kolban
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

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Sun Aug 05, 2018 3:48 pm
by mzimmers
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.

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Mon Aug 13, 2018 2:33 pm
by mzimmers
Anyone have any ideas on this one? I need to get this fixed.

Thanks...

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Mon Aug 13, 2018 3:52 pm
by fly135
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

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Wed Oct 10, 2018 4:31 pm
by mzimmers
BTT. This is an ongoing problem, and I really don't know how to recover from receiving this code.

Re: cause and cure for WIFI_REASON_ASSOC_TOOMANY?

Posted: Thu Jun 22, 2023 4:40 am
by kongshui
I have encountered the same problem. In ESP-IDF V5.1