Skip to content

Conversation

@j0KZ
Copy link

@j0KZ j0KZ commented Feb 5, 2026

Summary

  • Implements 30-second heartbeat pings to Nostr relay WebSocket connections
  • Detects and handles dead connections that may not trigger disconnect events
  • Improves connection reliability by proactively finding stale connections

Changes

  • Add heartbeatTimers dictionary and heartbeatInterval constant
  • Add startHeartbeat/stopHeartbeat/sendHeartbeatPing functions
  • Start heartbeat when connection is established
  • Stop heartbeat on disconnect or connection failure
  • Handle heartbeat failures by triggering reconnection with backoff

Test plan

  • Verify heartbeat starts after successful relay connection
  • Verify heartbeat stops on explicit disconnect
  • Simulate network failure and verify reconnection is triggered
  • Verify no memory leaks from timer management

🤖 Generated with Claude Code

Implements 30-second heartbeat pings to Nostr relay WebSocket connections
to detect and handle dead connections that may not trigger disconnect events.

Changes:
- Add heartbeatTimers dictionary and heartbeatInterval constant
- Add startHeartbeat/stopHeartbeat/sendHeartbeatPing functions
- Start heartbeat when connection is established
- Stop heartbeat on disconnect or connection failure
- Handle heartbeat failures by triggering reconnection with backoff

This improves connection reliability by proactively detecting stale
connections that appear connected but are no longer responsive.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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