Webserver runs out of sockets
Posted: Thu Sep 12, 2019 4:58 pm
I am using ESP-IDF the httpd webserver.
My webpage references many files, images etc.
Some HTTP clients make multiple requests before the last request has completed 'OK'.
This can cause ENFILE (23):
which I guess is being caused by
I have maxed the maximum number of open sockets.
Q) Does anyone have a patch e.g. stop httpd looping back into accept() until we have a free socket?
Q) Is the lwip socket limit per adaptor or per application?
My webpage references many files, images etc.
Some HTTP clients make multiple requests before the last request has completed 'OK'.
This can cause ENFILE (23):
Code: Select all
httpd_accept_conn() { ...
int new_fd = accept(listen_fd, (struct sockaddr *)&addr_from, &addr_from_len);
if (new_fd < 0) {
ESP_LOGW(TAG, LOG_FMT("error in accept (%d)"), errno);
return ESP_FAIL;
Code: Select all
lwip_accept() { ...
newsock = alloc_socket(newconn, 1);
if (newsock == -1) {
netconn_delete(newconn);
sock_set_errno(sock, ENFILE);
return -1;
Q) Does anyone have a patch e.g. stop httpd looping back into accept() until we have a free socket?
Q) Is the lwip socket limit per adaptor or per application?