-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hi,
I ran a small load test with K6 against a dummy WebSocket application using Cowboy. During the test, the system reached the maximum number of open ports. After hitting this limit, the Cowboy listener appears to enter an inconsistent state. For example:
❯ lsof -i :3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 6236 juliogc 39u IPv4 0xb0cec2ba38c3c8df 0t0 TCP *:hbci (CLOSED)
Here, the port shows as CLOSED and the server no longer accepts connections, even after the load test has stopped. Restarting the application or the Cowboy listener resolves the issue, but it seems like the server should be able to recover automatically.
Steps to Reproduce:
- Run a WebSocket server with Cowboy on macOS.
- Launch a high-load test (e.g., K6) to reach the system’s maximum number of open ports.
- Observe the listener state via lsof -i :.
- Attempt to connect — connections are refused.
Expected Behavior:
The Cowboy listener should either:
- Recover automatically after the system clears some sockets, or
- Fail gracefully with a clear error without making the port permanently unreachable.
Actual Behavior:
The listener stops accepting new connections silently and requires a manual restart.
Environment:
- macOS: Sonoma 14.6.1
- Erlang/OTP: 28
- Cowboy: 2.14.2
Notes:
This may be related to TIME_WAIT socket exhaustion or OS-level ephemeral port limits. A mechanism to gracefully handle port exhaustion would improve robustness under load.