Neo4j Bolt Handshake Protocol Introduced
2021-11-14A technical explanation of Neo4j's Bolt Handshake Protocol, detailing the client-server connection process with bit-level analysis of version negotiation and the three-step communication pattern used to establish database connections.
The Bolt Handshake Protocol Specification defines the protocol that allows a server and client to initiate a connection in Bolt Protocol.
This article provides an overview of the Bolt Handshake Protocol.
Handshake Workflow
The fundamental process for a client to establish a connection with a server is illustrated below:
First, the client declares its intent to initiate a connection using the Bolt Protocol by sending a fixed 4-byte message:
C: 60 60 B0 17
Next, the client sends four supported versions of the Bolt Protocol, each represented as a 32-bit unsigned integer in big-endian format.
For example, in the diagram above, the client supports the following four versions:
- v4.2:
00 00 02 04
- v4.1:
00 00 01 04
- v4.0:
00 00 00 04
- v3.x:
00 00 00 03
The client transmits these versions as the following bit sequence:
C: 00 00 02 04 00 00 01 04 00 00 00 04 00 00 00 03
The server selects a suitable Bolt Protocol version from the list and returns it to the client. Suppose the server chooses v4.1:
S: 00 00 01 04
Summary
To summarize, the following bit sequences are exchanged in total. The entire process requires three round-trips:
C: 60 60 B0 17
C: 00 00 02 04 00 00 01 04 00 00 00 04 00 00 00 03
S: 00 00 01 04
This concludes the overview of the Binary Handshake Protocol.