Skip to content

Make ping() wake the connection so keep-alives are sent when idle - #525

Open
aswanthk777 wants to merge 1 commit into
Tencent:developfrom
aswanthk777:bonding/idle-keepalive
Open

Make ping() wake the connection so keep-alives are sent when idle#525
aswanthk777 wants to merge 1 commit into
Tencent:developfrom
aswanthk777:bonding/idle-keepalive

Conversation

@aswanthk777

Copy link
Copy Markdown

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:

  • the 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. Full suite: 558/0.

🤖 Generated with Claude Code

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.
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.

1 participant