- Is this truly the maximum we will have in an ESP32 or is this just an "as of now" story?
- Does a "server socket" count against this number? For example, if I create a listening socket, does that reduce my number
of concurrently connected clients by 1? - What happens to a client connection if we are running a listener on ESP32 and the maximum is reached? Is it rejected or held pending an accept for a future connection?
[Answered] Maximum number of open sockets supported
[Answered] Maximum number of open sockets supported
Looking through the "menuconfig" settings we find a property within the "lwIP" area called "Max number of open sockets" which has a default of 4 and according to its help information, a maximum of 16. I am guessing that this is a constraint on the number of concurrently open sockets. I find myself surprised by a default of 4 and a maximum of 16. That "feels" low to me. That said, I have no evidence or experience that it would be a problem. A couple of questions though:
Last edited by kolban on Sun Oct 09, 2016 5:28 am, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 9709
- Joined: Thu Nov 26, 2015 4:08 am
Re: Maximum number of open sockets supported
I can't comment on what exactly LWIP (which is the TCP/IP stack we currently use) does when it hits the socket limit (except for returning -1 on a socket() call). I do know that for the ESP8266, 4 also was the minimum, and I've not heard many complaints about that. I'm not sure why 16 is chosen as the maximum number, but given that every potential open socket uses a bit of memory and LWIP is not designed for many simultaneous connections, I think that a maximum of 16 is reasonable.
Re: [Answered] Maximum number of open sockets supported
I don't think menuconfig option for the number of open sockets is used anywhere. It was added as an example of potential options which can be configured using menuconfig. But it isn't used in lwiptopts header file. Setting the number of sockets by itself is not the whole story, one also needs to set the number of TCP PCBs and some other parameters.
Re: [Answered] Maximum number of open sockets supported
Hi,
is the maximum number of open sockets equal to the size of the bitfield in struct fd_set ? Can i expect that select function on FD will work on current idf?
And what is the answer to the question? Can i tweak the number of open sockets by a define ?
is the maximum number of open sockets equal to the size of the bitfield in struct fd_set ? Can i expect that select function on FD will work on current idf?
And what is the answer to the question? Can i tweak the number of open sockets by a define ?
Creator of Smart Connected Devices - for EcSUHA.de Project
Re: [Answered] Maximum number of open sockets supported
I think the previous answer that "a maximum of 16 is reasonable" is outdated now.
I'm using ESP-WROVER with 4M of RAM. That should be plenty ram to support > 16 connections.
How can/should I increase LWIP_MAX_SOCKETS? Just hack the generated sdkconfig file?
I'm using ESP-WROVER with 4M of RAM. That should be plenty ram to support > 16 connections.
How can/should I increase LWIP_MAX_SOCKETS? Just hack the generated sdkconfig file?
Re: [Answered] Maximum number of open sockets supported
Just opening a web page on the server on ESP32 with one browser opens 4 sockets. So 16 sockets max doesn't seem like such a large number really. Additionally, when I close the browser window, it only closes one of the sockets, leaving 3 open. So with just a couple of closings and re-openings, the maximum is gobbled up and I start getting errors on the server that there aren't enough sockets available.
-
- Posts: 7
- Joined: Thu Aug 25, 2022 10:34 pm
Re: [Answered] Maximum number of open sockets supported
Has there been any updates to this? In the HTTP web server, the maximum of 13 open sockets isn't enough when you're potentially dealing with both websockets and regular HTTP requests.
Re: [Answered] Maximum number of open sockets supported
The way I've dealt with this limitation is to set the HTTP header "Connection: close\r\n". That tells the client to close every connection as soon as it is finished being used.
This has allowed me to serve static content and some APIs to several browsers and keep several websockets alive at once. I've seen no noticeable performance impact to closing unused connections (not sure if this would be true with SSL/HTTPS?).
On libesphttpd you can enable that feature by setting this in menuconfig: ESPHTTPD_SINGLE_REQUEST
This has allowed me to serve static content and some APIs to several browsers and keep several websockets alive at once. I've seen no noticeable performance impact to closing unused connections (not sure if this would be true with SSL/HTTPS?).
On libesphttpd you can enable that feature by setting this in menuconfig: ESPHTTPD_SINGLE_REQUEST
Who is online
Users browsing this forum: No registered users and 81 guests