feat: add non-blocking handshakes and tunnel health monitoring (#13)#21
Open
feat: add non-blocking handshakes and tunnel health monitoring (#13)#21
Conversation
- Spawn handshakes in separate tasks to avoid blocking accept loop - Add 60s timeout for incoming handshakes - Emit connection_error events on handshake timeout - Add tunnel_health_monitor task that checks SAM connectivity every 30s - Emit tunnel_healthy and tunnel_degraded events for status updates - Quick health check via SAM HELLO to verify tunnel responsiveness This implements issue #13 to improve resilience of accept_loop. Handshakes no longer block the accept loop, preventing multiple connection attempts from queuing indefinitely. Users receive feedback about tunnel health status, and the app can detect when the I2P tunnel becomes degraded.
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.
Feature: Add non-blocking handshakes and tunnel health monitoring (#13)
Closes #13
Problem
The
accept_loophas several resilience issues:Blocking handshakes: Each incoming handshake blocks the accept loop, preventing subsequent connection attempts from being processed. If multiple peers connect simultaneously, only one handshake proceeds at a time.
No timeouts: Incoming handshakes can hang indefinitely if the peer becomes unresponsive during the handshake, leaving the connection in a zombie state.
No tunnel health monitoring: There's no way to detect when the I2P tunnel becomes degraded or unresponsive. Users receive no feedback about tunnel status.
No status feedback: Users have no visibility into whether the tunnel is healthy or degraded, making troubleshooting difficult.
These issues are particularly problematic on I2P, where network conditions can be unstable and tunnels often degrade temporarily.
Solution
Implement non-blocking handshakes with tunnel health monitoring:
Non-blocking handshakes:
Handshake timeouts:
connection_errorevent on timeoutTunnel health monitoring:
tunnel_health_monitortask runs in parallel with accept_loopHealth status events:
tunnel_healthy: Emitted when tunnel is responsivetunnel_degraded: Emitted when tunnel is unresponsiveImplementation details
Benefits