Repeatedly connecting and disconnecting to AP breaks httpd_server

GreenLoofa
Posts: 1
Joined: Fri Mar 05, 2021 5:21 am

Repeatedly connecting and disconnecting to AP breaks httpd_server

Postby GreenLoofa » Fri Mar 05, 2021 5:28 am

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) {
case SYSTEM_EVENT_AP_STACONNECTED:
// Start webserver once client joins
if (*server == NULL) {
*server = start_webserver();
}
break;
case SYSTEM_EVENT_AP_STADISCONNECTED:
// Stop webserver once client leaves
/* Stop the web server */
if (*server) {
stop_webserver(*server);
*server = NULL;
}
break;
default:
break;
}
return ESP_OK;
}
```

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

Her Mary
Posts: 493
Joined: Mon Oct 27, 2014 11:09 am

Re: Repeatedly connecting and disconnecting to AP breaks httpd_server

Postby Her Mary » Thu Apr 22, 2021 5:10 pm

The latest RTOS 3.4 is just released recently, maybe you can have a try with the latest version to see if the issue persists.

Who is online

Users browsing this forum: No registered users and 4 guests