bye (2)

Finalized

The bye message is used to signal the graceful termination of a session. It can be sent by either peer at any time after the handshake is complete.

Upon sending or receiving a bye message, a node should immediately close the underlying TCP connection. The message includes a reason code and an optional descriptive text to aid in debugging.

Core Data Types

Payload Structure

FieldData TypeMinMaxDescription
reasonCodeint32A numeric code indicating the reason for the disconnection. See table below.
messagestringA human-readable UTF-8 string explaining the reason for disconnection.
datastringAdditional contextual data related to the reason.

Reason Codes (ProtocolByeCode)

The reasonCode field provides a specific, machine-readable reason for the disconnection.

CodeNameDescription
100blockInvalidThe peer sent a block that failed validation.
200byeNormal disconnection initiated by the peer.
400expectingMasterThe peer expected to connect to a Master Node but did not.
501deprecatedThe peer is using an obsolete protocol version that is no longer supported.
502incorrectNetworkTypeThe peer is on a different network (e.g., TestNet vs. MainNet).
599insufficientFundsThe peer, acting as a Master Node, does not meet the minimum required token balance.
600incorrectIpThe peer's IP address in its hello message signature was incorrect.
601notConnectableThe peer's advertised public address and port were not reachable for a connection test.
602tooFarBehindThe peer's blockchain is too far behind the network's current block height to sync efficiently.
603authFailedThe hello message signature verification failed.
604addressMismatchThe peer's address did not match the expected address, possibly indicating a MitM attack.
605rejectedThe connection was rejected for a non-specific reason (e.g., peer is blacklisted, server slots are full).
700notReadyThe node is not yet synchronized or ready to accept connections.

Behavioral Notes

  • Connection Teardown: Both the sender and receiver should immediately and cleanly close the socket after this message is sent or received.
  • No Response Expected: A bye message does not require a response.
  • Reconnect Logic: A client receiving a bye with a code other than 200 (bye) may attempt to reconnect later. A code of 200 typically implies a deliberate shutdown, and the client should not attempt to immediately reconnect.