0.3.82: relax TCP keepalive timings (Wi-Fi-friendly)#7
Merged
Conversation
v0.3.81 keepalive (idle=1s, interval=1s, count=3 → ~4s detection) was too aggressive. Brief mid-handshake pauses on Wi-Fi got the connection reaped before the application-level handshake exchange could complete, producing "session: handshake timeout after 10s — disconnecting" on healthy connections. v0.3.82: idle=10s, interval=30s, count=3 → ~100s to declare dead. Wi-Fi-friendly. Healthy connections survive ordinary network jitter. Application-layer lastSeen-stale check in addPeer (also from v0.3.81) still gives fast (~10s) peer-restart recovery; OS keepalive is the fallback for scenarios the application layer doesn't see. 71/71 unit tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
v0.3.81 set keepalive at `idle=1s, interval=1s, count=3` (~4s to declare dead) — far too aggressive for real-world Wi-Fi. Brief mid-handshake pauses on healthy connections got the socket reaped before the application-level handshake exchange could complete:
```
[SYM] session: connection ready (outbound=true)
[SYM] session: handshake timeout after 10s — disconnecting
```
Even fully-functional peers were producing this on the field on iPhone↔Mac-Catalyst pairs over Wi-Fi.
Fix
`idle=10s, interval=30s, count=3` → ~100s to declare dead. Wi-Fi-friendly: a few seconds of natural network jitter during handshake or quiet CMB flow doesn't trigger reaping. Peer-restart scenarios still recover within ~100s instead of macOS default ~2h.
The application-layer `lastSeen`-stale check in `SymNode.addPeer` (shipped in v0.3.81) still gives fast ~10s peer-restart recovery — that's the user-visible "peer restarted, reconnect now" path. OS keepalive is the slower fallback for cases the application layer doesn't see.
Tests
71/71 existing unit tests pass.
🤖 Generated with Claude Code