Make ping() wake the connection so keep-alives are sent when idle - #525
Open
aswanthk777 wants to merge 1 commit into
Open
Make ping() wake the connection so keep-alives are sent when idle#525aswanthk777 wants to merge 1 commit into
aswanthk777 wants to merge 1 commit into
Conversation
Connection::ping() only sets need_send_ping on the target path(s). It
does not mark the connection tickable, and Endpoint::process_connections
only processes tickable connections — so on a busy connection the PING
piggybacks on other traffic, but on a truly idle connection (the exact
case a keep-alive exists for) nothing ever flushes it:
- app calls conn.ping(None) every few seconds
- need_send_ping is set, but the connection is never processed
- no packet is sent; the peer stays silent too
- both ends remain dark until the idle timeout — or until an
application-level liveness check ("no packets received for N
seconds") closes a perfectly healthy connection
Observed live: a tunnel using ping(None) as its 5s keep-alive plus a
15s no-receive liveness check entered a close/redial loop every ~20s
whenever it carried no user traffic. The bug is masked by any ambient
traffic, which is why it survives the existing test suite: TestPair
drives connections directly rather than through Endpoint scheduling.
Fix: mark the connection tickable in ping(), the same wake-up used by
the recv path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connection::ping()only setsneed_send_pingon the target path(s). It does not mark the connection tickable, andEndpoint::process_connectionsonly processes tickable connections — so on a busy connection the PING piggybacks on other traffic, but on a truly idle connection (the exact case a keep-alive exists for) nothing ever flushes it:conn.ping(None)every few secondsneed_send_pingis set, but the connection is never processedObserved live: a tunnel using
ping(None)as its 5s keep-alive plus a 15s no-receive liveness check entered a close/redial loop every ~20s whenever it carried no user traffic. The bug is masked by any ambient traffic, which is why it survives the existing test suite (TestPair drives connections directly rather than through Endpoint scheduling).Fix: mark the connection tickable in
ping(), the same wake-up used by the recv path. Full suite: 558/0.🤖 Generated with Claude Code