Skip to content

CP 10 has 4 stream sockets; CP 9 had 8 #10606

@anecdata

Description

@anecdata

CircuitPython version and board name

Adafruit CircuitPython 9.2.8 on 2025-05-28; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3
vs.
Adafruit CircuitPython 10.0.0-beta.3 on 2025-08-29; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3

Code/REPL

import time
import wifi
import socketpool

time.sleep(3)  # wait for serial after reset
pool = socketpool.SocketPool(wifi.radio)
socks = []
while True:
    socks.append(pool.socket(pool.AF_INET, pool.SOCK_STREAM))
    time.sleep(1)  # just in case
    print(f"{len(socks)}")  # 8 in CP 9; 4 in CP 10

Behavior

CP 9:

1
2
3
4
5
6
7
8
Traceback (most recent call last):
  File "code.py", line 9, in <module>
RuntimeError: Out of sockets

CP 10:

1
2
3
4
Traceback (most recent call last):
  File "code.py", line 9, in <module>
RuntimeError: Out of sockets

Description

This is a relatively significant regression. We changed from 4 to 8 three years ago. Clients may need to have multiple sockets in use (HTTP, MQTT, NTP, etc... 2 sockets per TLS TCP connection). HTTPS Server uses 1 socket for listen, and 1 for each connected client (more with SSL, websockets, or HTTP/TCP client within a route or elsewhere).

Additional information

CONFIG_LWIP_MAX_SOCKETS=8 hasn't changed in https://github.com/adafruit/circuitpython/tree/main/ports/espressif/esp-idf-config/sdkconfig.defaults and I didn't spot any overrides in lower-level config files

These also were the same in CP 9:

CONFIG_LWIP_MAX_ACTIVE_TCP=4
CONFIG_LWIP_MAX_LISTENING_TCP=4

but if I interpret those right, they wouldn't kick in right at socket creation
(BTW, we could increase both of these, Espressif defaults are higher, and docs indicate there's little memory impact of higher limits... until used by active sockets)

I reviewed ESP-IDF changes from v5.3.2 to v5.4.1, but nothing jumped out at me.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions