Skip to content

fix: ensure client keepalive < server keepalive to avoid client keepalive desync errors - #1555

Merged
ananthsub merged 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ananthsub/client-server-keepalive-timeouts
Jun 23, 2026
Merged

ananthsub merged 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ananthsub/client-server-keepalive-timeouts

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

uvicorn closes idle keep-alive connections after 5s by default (ref)

while the aiohttp client keeps them pooled for 15s by default (ref), causing ServerDisconnectedError when the client reuses a socket the server already closed.

This PR set the client TCPConnector keepalive_timeout to 15s and the uvicorn timeout_keep_alive to 30s so pooled sockets are guaranteed live when reused.

cmunley1
cmunley1 previously approved these changes Jun 10, 2026
Comment thread nemo_gym/server_utils.py Resolved
@ananthsub
ananthsub force-pushed the ananthsub/client-server-keepalive-timeouts branch from b7a8b6e to b04120b Compare June 10, 2026 08:37
@ananthsub
ananthsub requested a review from cmunley1 June 10, 2026 09:10
@ananthsub
ananthsub force-pushed the ananthsub/client-server-keepalive-timeouts branch from b04120b to 2235ecc Compare June 11, 2026 03:34
@copy-pr-bot

copy-pr-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ananthsub
ananthsub force-pushed the ananthsub/client-server-keepalive-timeouts branch from 2235ecc to 46c9356 Compare June 16, 2026 17:08
@ananthsub
ananthsub enabled auto-merge (squash) June 16, 2026 17:25
@ananthsub
ananthsub force-pushed the ananthsub/client-server-keepalive-timeouts branch 2 times, most recently from 2294f57 to d6d4269 Compare June 23, 2026 16:40
…nectedError

uvicorn closes idle keep-alive connections after 5s by default while the
aiohttp client keeps them pooled for 15s, causing ServerDisconnectedError
when the client reuses a socket the server already closed. Set the client
TCPConnector keepalive_timeout to 15s and the uvicorn timeout_keep_alive to
30s so pooled sockets are guaranteed live when reused.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
@ananthsub
ananthsub force-pushed the ananthsub/client-server-keepalive-timeouts branch from d6d4269 to 26f3b66 Compare June 23, 2026 21:43
@ananthsub
ananthsub disabled auto-merge June 23, 2026 21:48
@ananthsub
ananthsub merged commit 1c8b855 into NVIDIA-NeMo:main Jun 23, 2026
15 checks passed
@ananthsub
ananthsub deleted the ananthsub/client-server-keepalive-timeouts branch June 23, 2026 21:48
ritaneves pushed a commit that referenced this pull request Jun 25, 2026
…live desync errors (#1555)

uvicorn closes idle keep-alive connections after 5s by default
([ref](https://uvicorn.dev/settings/#timeouts))

while the aiohttp client keeps them pooled for 15s by default
([ref](https://docs.aiohttp.org/en/stable/client_reference.html#connectors)),
causing ServerDisconnectedError when the client reuses a socket the
server already closed.

This PR set the client TCPConnector `keepalive_timeout` to 15s and the
uvicorn `timeout_keep_alive` to 30s so pooled sockets are guaranteed
live when reused.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Signed-off-by: Rita Fernandes Neves <rfernandesne@nvidia.com>
haifengqian added a commit to haifengqian/NeMo-Gym-fork that referenced this pull request Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants