Software:Bolt (network protocol)

From HandWiki
Bolt
Original author(s)Neo Technology
Stable release
Version 1
Written inVarious languages
Operating systemAny
PlatformCross-platform
TypeNetwork protocol
LicenseCreative Commons 3.0 Attribution-ShareAlike
Websiteboltprotocol.org

The Bolt Protocol (Bolt) is a connection oriented network protocol used for client-server communication in database applications. It operates over a TCP connection or WebSocket.

Bolt is statement-oriented, allowing a client to send messages containing a statement consisting of a single string and a set of typed parameters. The server responds to each statement with a result message and an optional stream of result records.

History

The Bolt protocol was first introduced to the public in November 2015, during an interview conducted by Duncan Brown and published on DZone.[1] The first release of software implementing the protocol occurred in December 2015, as part of a milestone release of Neo4j Server.[2] In April 2016, Neo4j Server 3.0 was released and contained the first server implementation of the protocol, accompanied by a suite of Bolt client drivers. This release received attention from several mainstream media outlets.[3][4][5]

Versioning

The protocol supports explicit versioning and version negotiation between the client and the server. There is only one published version of the protocol: version 1.

Protocol overview - version 1

Messaging

A typical interaction in the Bolt network protocol

Bolt clients and servers both send data over the connection as a sequence of messages. Each message has a type (denoted by a "signature" byte) and may include additional data. The client drives the interaction, and each message sent by the client will cause one or more response messages to be sent by the server.

Client messages:

Type Signature
INIT 0x01[6]
RUN 0x10[7]
DISCARD_ALL 0x2F[8]
PULL_ALL 0x3F[9]
ACK_FAILURE 0x0E[10]
RESET 0x0F[11]

Server messages:

Type Signature
SUCCESS 0x70[12]
FAILURE 0x7F[13]
IGNORED 0x7E[14]
RECORD 0x71[15]

Message transfer encoding

Each message is encoded into a sequence of bytes. These bytes are transferred using a binary chunked encoding, where each chunk is preceded by an unsigned, big-endian 16-bit integer denoting the number of bytes that immediately follow. A length of 0 is used to denote the end of the message.

Failure handling

A client may send multiple messages to a server, without first waiting for a response.[16] The server processes each message sequentially. However, as there may be logical dependencies between messages sent by the client, the server will not evaluate requests it receives after sending FAILURE in response to a preceding message. Instead, it will send an IGNORED message in reply to every client message, until the client acknowledges the failure by sending an ACK_FAILURE message.

This is similar to the failure handling and recovery in the PostgreSQL wire protocol.

Data encoding

Bolt supports encoding for a number of different data types.

Type Description
Null[17] Represents the absence of a value.
Boolean[18] Boolean true or false.
Integer[19] 64-bit signed integer.
Float[20] 64-bit floating point number.
String[21] UTF-8 encoded string.
List[22] Ordered collection of values.
Map[23] Unordered, keyed collection of values.
Node[24] A node in a Property Graph with optional properties and labels.
Relationship[25] A directed, typed connection between two nodes in a Property Graph. Each relationship may have properties and always has an identity.
Path[26] The record of a directed walk through a Property Graph, consisting of a sequence of zero or more segments.

References

  1. "Introducing Bolt, Neo4j's Upcoming Binary Protocol – Part 1 - DZone Database". https://dzone.com/articles/introducing-bolt-neo4js-upcoming-binary-protocol-p. Retrieved June 2, 2017. 
  2. "Bolting Forward: The Neo4j 3.0 Milestone 1 Release Is Here - Neo4j Graph Database". December 4, 2015. https://neo4j.com/blog/neo4j-3-0-milestone-1-release/. Retrieved June 2, 2017. 
  3. Martin, Alexander J. (26 April 2016). "Neo4j bolts on binary protocol to up its graph database game". https://www.theregister.co.uk/2016/04/26/neo4j_bolts_on_binary_protocol_to_up_graph_database_game/. Retrieved June 2, 2017. 
  4. "Neo4j 3.0 Released with Binary Communication Protocol and Standardised Drivers". https://www.infoq.com/news/2016/04/neo4j-3.0. Retrieved June 2, 2017. 
  5. "Neo Technology Releases Neo4j 3.0". April 26, 2016. http://www.tomsitpro.com/articles/neo-technology-releases-neo4j-3,1-3253.html. Retrieved June 2, 2017. 
  6. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-init. Retrieved June 2, 2017. 
  7. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-run. Retrieved June 2, 2017. 
  8. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-discard-all. Retrieved June 2, 2017. 
  9. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-pull-all. Retrieved June 2, 2017. 
  10. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-ack-failure. Retrieved June 2, 2017. 
  11. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-reset. Retrieved June 2, 2017. 
  12. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-success. Retrieved June 2, 2017. 
  13. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-failure. Retrieved June 2, 2017. 
  14. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-ignored. Retrieved June 2, 2017. 
  15. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#message-record. Retrieved June 2, 2017. 
  16. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#pipelining. Retrieved June 2, 2017. 
  17. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#null. Retrieved June 2, 2017. 
  18. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#booleans. Retrieved June 2, 2017. 
  19. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#ints. Retrieved June 2, 2017. 
  20. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#floats. Retrieved June 2, 2017. 
  21. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#strings. Retrieved June 2, 2017. 
  22. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#lists. Retrieved June 2, 2017. 
  23. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#maps. Retrieved June 2, 2017. 
  24. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#node-structure. Retrieved June 2, 2017. 
  25. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#rel-structure. Retrieved June 2, 2017. 
  26. "Bolt Protocol, Version 1". http://boltprotocol.org/v1/#path-structure. Retrieved June 2, 2017. 

External links