Page 1 of 1

HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

Posted: Wed Apr 17, 2019 10:19 am
by bewatermyfriendxd
Hello,

Im using a webserver on my ESP32 which provides functions I can access from the web page via HTTP methods.
On one page I poll values from the ESP32 using JavaScript code like this:

Code: Select all

var xhr = new XMLHttpRequest();
xhr.open("POST", '/server/readADC', true);

xhr.onreadystatechange = function() 
{
    if (this.readyState === 4 && this.status === 200) {
        // Visualize data on the website
    }
}
The problem is, the server stops responding after a few requests.
After some time I get this error on the ESP32 side.

W (582011) httpd: httpd_accept_conn: error in accept (23)
W (582011) httpd: httpd_server: error accepting new connection
W (582021) httpd: httpd_accept_conn: error in accept (23)
W (582021) httpd: httpd_server: error accepting new connection
W (583011) httpd: httpd_accept_conn: error in accept (23)


Ive configured the http server with HTTPD_DEFAULT_CONFIG() value.
How am I able to continuously fetch data from the http server?

I'll appreciate any help. Thanks for the support.

Re: HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

Posted: Thu Apr 18, 2019 9:08 am
by bewatermyfriendxd
I could fix this issue by modifying the http_config struct I used to initialize the http server.
When using the macro HTTPD_DEFAULT_CONFIG() the field lru_pruge_enable is set to false.
I had to set this true.

This field is described as
Purge "Least Recently Used" connection
.
When doing something like polling from JavaScript a lot of requests are sent to the http_server, for each a new session is opened by the internal socket. At some point the socket cant keep up anymore. By setting this field the socket throws away the last session and replaces it with the new request. So all requests can be properly handled.

Re: HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

Posted: Fri May 08, 2020 7:41 pm
by guillep2k
Thank you! Solved this problem for me.

Re: HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

Posted: Sat May 09, 2020 5:43 pm
by rsimpsonbusa
Hi everybody.

Have u tried max_open_sockets=1; //just one connection

Does it have the same effect, by forcing just one connection?

BTW, I am guessing that the standard 4 connections WILL eat up genereal max connections to the ESP32 that could be needed.

RSN

Re: HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

Posted: Sat May 09, 2020 6:13 pm
by rsimpsonbusa
A question.

Are you connected to the ESP32 via the STA or the AP interface? If its the AP (let say the STA disabled) one cannot send a jquery since it can not download the jquery lib to the browser unless in a desktop (LAN inteface).

Thanks

RSN

Re: HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

Posted: Thu Jul 30, 2020 1:37 am
by ht_main1

Code: Select all

[0;32mI (243969) HTTP SERVER:: Index page[0m
[0;33mW (243969) httpd: httpd_accept_conn: error in accept (23)[0m
[0;33mW (243969) httpd: httpd_server: error accepting new connection[0m
[0;32mI (244009) HTTP SERVER:: app css page[0m
[0;32mI (244069) HTTP SERVER:: normalize css page[0m
[0;32mI (244109) HTTP SERVER:: style css page[0m
[0;32mI (244119) HTTP SERVER:: page css page[0m
[0;33mW (244189) httpd: httpd_accept_conn: error in accept (23)[0m
i have got same problem but on STA mode, i have also set config.lru_purge_enable = true; but in STA mode it doesnt i get same error,
when i tried same in AP mode i got no error and application loaded completely.

i have 31 uri , in sta mode i can see some uri are not loaded, but same thing doesnt happen in AP mode.

can some one guide me to resolve issue ?