You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Tool bridge creates excessive TIME_WAIT connections — need connection pooling for tcp://127.0.0.1:3003 #41612
Confirming this on macOS — with much more severe consequences than the Windows report.
Environment:
Hermes gateway × 2 (hermes_cli.main gateway run --replace, one with --profile finance), running unattended for ~1 month
macOS 26 (Darwin 25.2.0), Apple Silicon Mac mini, uptime 50 days
Outbound traffic routed through a local Clash proxy on 127.0.0.1:7890
What happened:
27,000+ TIME_WAIT sockets accumulated (netstat -an -p tcp | grep -c TIME_WAIT), of which 7,151 targeted 127.0.0.1:7890 (the local proxy) — same no-reuse, connect-per-call pattern described above. The storm was amplified when the proxy app was restarted on a different port: hermes kept hammering the dead port with retries (likely related: the zero-backoff retry path in [Enhancement] Empty response retries have no backoff delay — immediate retry wastes API calls #35230).
macOS's default ephemeral port range (49152–65535, 16,384 ports) was fully exhausted. Every new outbound TCP connection failed with EADDRNOTAVAIL ("Can't assign requested address") — the macOS equivalent of the WSAENOBUFS (10055) in the original report.
The machine became effectively network-dead for TCP: curl to any host failed in ~1ms, even nc 127.0.0.1 22 failed. Only ICMP/ping and DNS (existing UDP sockets) still worked. The gateway processes themselves were wedged hard enough that they no longer responded to SIGTERM — only kill -9 worked.
Killing the two gateway processes instantly restored all TCP connectivity, confirming hermes held the exhausted ports.
+1 for connection pooling / socket reuse (#41638). A capped retry with jittered_backoff on the bridge/proxy connect path would also prevent the dead-port hammering variant.
One PR addresses the open issue #41612. #41638 modifies the RPC client path, but its diff adds documentation and reconnect-on-error logic rather than introducing the requested pooling: the module-global socket was already reused on main.
Related pull requests
fix(41612): Reuse RPC socket across tool calls to prevent TIME_WAIT buildup on Windows #41638[closed]unrelated — (+41/-11) — unrelated: The diff preserves the existing module-global _sock reuse and mainly adds a reconnect-and-retry path, so it does not fix the claimed connect-per-call cause. The closed PR remains relevant as an attempted fix, but the maintainer-bot close verdict further notes that tools/code_execution_tool.py:505-524 exits after the first client disconnects, making the proposed replacement-client retry incompatible with the server lifecycle; the contributor-reported stale-conn defect was corrected in d4972a6 but does not resolve that lifecycle mismatch.
Suggested consolidation
Keep #41638 closed as already implemented on main, consistent with the maintainer-bot verdict: its cited evidence is tools/code_execution_tool.py:350-381 and :390-400, where the cached client socket is created only when absent and then reused, with Windows loopback support attributed there to e93bfc6c93bfa6f9edd02629a03f717fc29ce013. There are no competing PRs or duplicate PRs to consolidate; #41612 remains open, so any further work should first reproduce the reported socket growth against current main and identify a cause outside the already-cached RPC client path.
Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 3 kB of PR diffs, 5 kB of issue/PR text, 4 kB of discussion (4 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
The per-call connect/close lifecycle that produced TIME_WAIT growth is gone: execute_code now runs a session-persistent kernel (#94647, b39d76d) that serves RPC over one connection for the kernel's whole life (tools/code_kernel.py::_rpc_forever, HERMES_RPC_PERSISTENT=1), and the client stub reuses a module-global socket under a lock (tools/code_execution_tool.py), reconnecting only after the 300 s idle disconnect. There is no fixed :3003 bridge anywhere in the tree (ephemeral loopback port on Windows, UDS elsewhere). Credit to @iamlukethedev (#41638) for the socket-reuse idea.
@Mrchen116's data point (7,151 TIME_WAIT to a local Clash proxy on :7890) is outbound HTTP through a proxy — a different mechanism tracked under #35230, not the tool bridge.
Activity
Mrchen116 commentedon Jun 11, 2026
Confirming this on macOS — with much more severe consequences than the Windows report.
Environment:
hermes_cli.main gateway run --replace, one with--profile finance), running unattended for ~1 month127.0.0.1:7890What happened:
netstat -an -p tcp | grep -c TIME_WAIT), of which 7,151 targeted127.0.0.1:7890(the local proxy) — same no-reuse, connect-per-call pattern described above. The storm was amplified when the proxy app was restarted on a different port: hermes kept hammering the dead port with retries (likely related: the zero-backoff retry path in [Enhancement] Empty response retries have no backoff delay — immediate retry wastes API calls #35230).EADDRNOTAVAIL("Can't assign requested address") — the macOS equivalent of theWSAENOBUFS (10055)in the original report.curlto any host failed in ~1ms, evennc 127.0.0.1 22failed. Only ICMP/ping and DNS (existing UDP sockets) still worked. The gateway processes themselves were wedged hard enough that they no longer responded to SIGTERM — onlykill -9worked.Repro signal for anyone checking their own box:
+1 for connection pooling / socket reuse (#41638). A capped retry with
jittered_backoffon the bridge/proxy connect path would also prevent the dead-port hammering variant.GottZ commentedon Jul 31, 2026
Summary
One PR addresses the open issue #41612. #41638 modifies the RPC client path, but its diff adds documentation and reconnect-on-error logic rather than introducing the requested pooling: the module-global socket was already reused on main.
Related pull requests
unrelated— (+41/-11) — unrelated: The diff preserves the existing module-global_sockreuse and mainly adds a reconnect-and-retry path, so it does not fix the claimed connect-per-call cause. The closed PR remains relevant as an attempted fix, but the maintainer-bot close verdict further notes thattools/code_execution_tool.py:505-524exits after the first client disconnects, making the proposed replacement-client retry incompatible with the server lifecycle; the contributor-reported stale-conndefect was corrected in d4972a6 but does not resolve that lifecycle mismatch.Suggested consolidation
Keep #41638 closed as already implemented on main, consistent with the maintainer-bot verdict: its cited evidence is
tools/code_execution_tool.py:350-381and:390-400, where the cached client socket is created only when absent and then reused, with Windows loopback support attributed there toe93bfc6c93bfa6f9edd02629a03f717fc29ce013. There are no competing PRs or duplicate PRs to consolidate; #41612 remains open, so any further work should first reproduce the reported socket growth against current main and identify a cause outside the already-cached RPC client path.Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 3 kB of PR diffs, 5 kB of issue/PR text, 4 kB of discussion (4 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
kshitijk4poor commentedon Sep 20, 2026
Closing as fixed on
main.The per-call connect/close lifecycle that produced TIME_WAIT growth is gone:
execute_codenow runs a session-persistent kernel (#94647, b39d76d) that serves RPC over one connection for the kernel's whole life (tools/code_kernel.py::_rpc_forever,HERMES_RPC_PERSISTENT=1), and the client stub reuses a module-global socket under a lock (tools/code_execution_tool.py), reconnecting only after the 300 s idle disconnect. There is no fixed:3003bridge anywhere in the tree (ephemeral loopback port on Windows, UDS elsewhere). Credit to @iamlukethedev (#41638) for the socket-reuse idea.@Mrchen116's data point (7,151 TIME_WAIT to a local Clash proxy on :7890) is outbound HTTP through a proxy — a different mechanism tracked under #35230, not the tool bridge.