Page 1 of 1

Repeatedly connecting and disconnecting to AP breaks httpd_server

Posted: Fri Mar 05, 2021 5:28 am
by GreenLoofa
Using the ESP8266 in AP mode (WIFI_MODE_AP) with the ESP8266_RTOS_SDK-3.2, I am noticing that the httpd server that I have running seems to stop responding to requests after repeated connects and disconnects.

Effectively, I want the httpd server to start up when a device connects to the esp8266's access point. Then I want to remove that web server when that device disconnects to the esp8266's access point. I find that when a device repeatedly connects and disconnects to the esp8266's access point, the httpd server stops responding to requests and outputs these errors instead:

httpd: httpd_accept_conn: error in accept (23)
httpd: httpd_server: error accepting new connection.

I have the server starting up in a wifi_event_handler like so:

esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
httpd_handle_t *server = (httpd_handle_t *) ctx;
/* For accessing reason codes in case of disconnection */
// system_event_info_t *info = &event->event_info;

ESP_LOGI(TAG, "Handle incoming wifi event");

switch(event->event_id) {
// Start webserver once client joins
if (*server == NULL) {
*server = start_webserver();
// Stop webserver once client leaves
/* Stop the web server */
if (*server) {
*server = NULL;
return ESP_OK;

I'm wondering if anyone has also experienced this, or if I am just missing something