HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

bewatermyfriendxd
Posts: 21
Joined: Wed Apr 03, 2019 1:29 pm

HTTP_Server: Error accepting connections when polling webserver functions from JavaScript

Postby bewatermyfriendxd » Wed Apr 17, 2019 10:19 am

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.

bewatermyfriendxd
Posts: 21
Joined: Wed Apr 03, 2019 1:29 pm

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

Postby bewatermyfriendxd » Thu Apr 18, 2019 9:08 am

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.

guillep2k
Posts: 13
Joined: Tue Feb 12, 2019 8:39 pm

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

Postby guillep2k » Fri May 08, 2020 7:41 pm

Thank you! Solved this problem for me.

rsimpsonbusa
Posts: 131
Joined: Tue May 17, 2016 8:12 pm

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

Postby rsimpsonbusa » Sat May 09, 2020 5:43 pm

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

rsimpsonbusa
Posts: 131
Joined: Tue May 17, 2016 8:12 pm

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

Postby rsimpsonbusa » Sat May 09, 2020 6:13 pm

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

ht_main1
Posts: 28
Joined: Sun Oct 06, 2019 6:08 pm

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

Postby ht_main1 » Thu Jul 30, 2020 1:37 am

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 ?

Who is online

Users browsing this forum: Gaston1980, Majestic-12 [Bot] and 397 guests