Wifi Sta Disconnect Reason explanation

impulstek
Posts: 2
Joined: Wed May 17, 2017 9:00 pm

Wifi Sta Disconnect Reason explanation

Postby impulstek » Wed May 17, 2017 9:55 pm

I am confused with various wifi station disconnect reason code, I lookup to this definition in `user_interface.h`

Code: Select all

   REASON_UNSPECIFIED              = 1,
   REASON_AUTH_EXPIRE              = 2,
   REASON_AUTH_LEAVE               = 3,
   REASON_ASSOC_EXPIRE             = 4,
   REASON_ASSOC_TOOMANY            = 5,
   REASON_NOT_AUTHED               = 6,
   REASON_NOT_ASSOCED              = 7,
   REASON_ASSOC_LEAVE              = 8,
   REASON_ASSOC_NOT_AUTHED         = 9,
   REASON_DISASSOC_PWRCAP_BAD      = 10,  /* 11h */
   REASON_DISASSOC_SUPCHAN_BAD     = 11,  /* 11h */
   REASON_IE_INVALID               = 13,  /* 11i */
   REASON_MIC_FAILURE              = 14,  /* 11i */
   REASON_4WAY_HANDSHAKE_TIMEOUT   = 15,  /* 11i */
   REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,  /* 11i */
   REASON_IE_IN_4WAY_DIFFERS       = 17,  /* 11i */
   REASON_GROUP_CIPHER_INVALID     = 18,  /* 11i */
   REASON_PAIRWISE_CIPHER_INVALID  = 19,  /* 11i */
   REASON_AKMP_INVALID             = 20,  /* 11i */
   REASON_UNSUPP_RSN_IE_VERSION    = 21,  /* 11i */
   REASON_INVALID_RSN_IE_CAP       = 22,  /* 11i */
   REASON_802_1X_AUTH_FAILED       = 23,  /* 11i */
   REASON_CIPHER_SUITE_REJECTED    = 24,  /* 11i */

   REASON_BEACON_TIMEOUT         = 200,
   REASON_NO_AP_FOUND              = 201,
   REASON_AUTH_FAIL            = 202,
   REASON_ASSOC_FAIL            = 203,
   REASON_HANDSHAKE_TIMEOUT      = 204,


I understand some of them, like reason 8 when I changed my station config to other SSID, and reason 201 when config set to station only and the wifi router turned off. I also observe that reason 201 only happen in STA mode and not in STA+AP mode.
Where can I find the explanation for wifi event, reason and corresponding wifi mode that trigger them?


So here's the story, I have several devices all using esp8266 with setup like this

Image

While the monitor device waiting (2 to 10 minutes) no network activity or connection opened, and in the meantime wifi sometimes disconnect 1 or 2 times with reason 6, 4, or 2 and fortunately the wifi always reconnect immediately.
why wifi disconnect with REASON_AUTH_LEAVE & REASON_NOT_AUTHED while the AP using AUTH_OPEN ?

And when waiting time expired, the monitor device start opening TCP connection and connection always broken, then reconnect again.
Are this behavior designed by espressif? to make esp8266 lose connection while the network inactive

thanks.

NOTE: monitor device use sdk 2.0, the other use sdk 1.5.2.

pratik

Re: Wifi Sta Disconnect Reason explanation

Postby pratik » Thu May 18, 2017 8:41 pm

I think there is something to do with the code you wrote, or might be frequency offset issue too.
Note that the reason/cause returned is not always reliable. Try connecting to a secure router (WPA2 or something) and see what happens.

Also, STA+AP mode may get disconnected because STA and AP both use same channel. So when you connect to a new AP or actively scan for APs, the AP mode may not be stable.

Inquisitor
Posts: 22
Joined: Thu Dec 14, 2017 10:53 am
Contact:

Re: Wifi Sta Disconnect Reason explanation

Postby Inquisitor » Mon Oct 04, 2021 9:36 pm

pratik wrote:I think there is something to do with the code you wrote, or might be frequency offset issue too.
Note that the reason/cause returned is not always reliable. Try connecting to a secure router (WPA2 or something) and see what happens.

Also, STA+AP mode may get disconnected because STA and AP both use same channel. So when you connect to a new AP or actively scan for APs, the AP mode may not be stable.


Thank you for your post.
I know this thread is very old, but I stumbled across it trying to understand my connection woes. It made perfect sense... that if you're scanning (which checks all channels) will cause your station connection to disconnect when the hardware is not on its channel. A little embarrassing that I didn't think of that.

As I have not found anything from Espressif giving more detail than the names on the enum in the user_interface.h, I did stumble across this link that describes Linux reasons that "sound" similar. On that link, are other links to IEEE and Cisco references that may help you. It did help me.
https://aboutcher.co.uk/2012/07/linux-wifi-deauthenticated-reason-codes/
3 lines of code = App/Web Server w/ GUI Admin, File Mngr, OTA, AP Mgr, Perf Metrics, WebSocket Comms, App API, All running on ESP8266... Even usable on ESP-01S
https://www.esp8266.com/viewtopic.php?f=11&t=23535
https://InqOnThat.com

Who is online

Users browsing this forum: No registered users and 237 guests