Skip to content

Remote comms: Intentional disconnect handling #685

@sirtimid

Description

@sirtimid

Problem: Currently, when a peer deliberately closes a connection (indicated by SCTP_USER_INITIATED_ABORT with cause code 12), we detect it but still trigger automatic reconnection. This wastes resources and ignores the peer's intent to close the connection.

Expected Behavior:

  • Detect intentional disconnects (SCTP_USER_INITIATED_ABORT / cause code 12)
  • Do not automatically reconnect when the disconnect was intentional
  • Provide an explicit mechanism for closing connections (e.g., closeConnection(peerId))
  • Track which peers have intentionally disconnected and require explicit reconnection

Implementation:

  • Modify readChannel in network.ts to distinguish intentional disconnects from failures
  • Add state tracking for intentionally closed connections
  • Prevent handleConnectionLoss from starting reconnection for intentional disconnects
  • Add API for explicit connection closure (possibly in RemoteManager or initNetwork return)

Acceptance Criteria:

  • Intentional disconnects are detected and logged appropriately
  • No automatic reconnection occurs after intentional disconnect
  • Explicit close mechanism is available and tested
  • Reconnection can be manually triggered after intentional close if needed

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions