Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Keep-alive for TCP #13543

Closed
MKRhere opened this issue Jan 30, 2022 · 0 comments · Fixed by #13103
Closed

Feature request: Keep-alive for TCP #13543

MKRhere opened this issue Jan 30, 2022 · 0 comments · Fixed by #13103

Comments

@MKRhere
Copy link
Contributor

MKRhere commented Jan 30, 2022

From RFC1122 4.2.3.6,

Implementors MAY include "keep-alives" in their TCP
implementations, although this practice is not universally
accepted.  If keep-alives are included, the application MUST
be able to turn them on or off for each TCP connection, and
they MUST default to off.

Currently, Deno.listen and Deno.connect occasionally seem to become stale when kept open for a while without any packets (a waiting connection). It doesn't close the connection, and doesn't error out, just becomes unresponsive on both sides until you try to write a packet. This causes me to be unable to free up resources from zombie connections.

As far as I understand, this is due to not sending keep-alive probes. Node has the socket.setKeepAlive API that I'm missing on Deno.

Implementing this might simply be setting the SO_KEEPALIVE, TCP_KEEPIDLE, TCP_KEEPCNT, TCP_KEEPINTVL options on the socket Linux Windows.

A possible Deno API may look like conn.setKeepAlive(interval)

Further reading:

I found this article that seems to describe the exact behaviour I'm facing, and the solution (keep-alive): https://holmeshe.me/network-essentials-setsockopt-SO_KEEPALIVE/#To-detect-an-absent-peer

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 a pull request may close this issue.

1 participant