Bolt (network protocol)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Bolt
Original authorNeo4j
Stable release
Version 5.8
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Written inVarious languages
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemAny
    PlatformCross-platform
    TypeNetwork protocol
    LicenseCreative Commons 3.0 Attribution-ShareAlike
    Websitewww.neo4j.com/docs/bolt/current/

    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

    [edit | edit source]

    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

    [edit | edit source]

    The Bolt network protocol uses version negotiation to ensure compatibility between clients and servers. Clients send up to four supported protocol versions, encoded as 32-bit integers, prioritizing earlier entries. The server responds with the highest compatible version or a zero value if no match is found, closing the connection. Starting with Bolt 4.0, the protocol supports major and minor versioning. Bolt 4.3 introduced range-based minor versioning, allowing clients to specify consecutive minor versions compactly.[6]

    Protocol overview

    [edit | edit source]

    Protocol new versions are released regularly, introducing enhancements in performance, functionality, and compatibility.

    Messaging

    [edit | edit source]
    File:Bolt-typical-interaction.png
    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.

    The following information pertains to Bolt version 5.8 and may not reflect the latest developments in the protocol.

    Client messages:

    Type Signature
    HELLO 0x01[7]
    LOGON 0x6A[8]
    LOGOFF 0x6B[9]
    TELEMETRY 0x54[10]
    GOODBYE 0x02[11]
    RESET 0x0F[12]
    RUN 0x10[13]
    DISCARD 0x2F[14]
    PULL 0x3F[15]
    BEGIN 0x11[16]
    COMMIT 0x12[17]
    ROLLBACK 0x13[18]
    ROUTE 0x66[19]

    Server messages:

    Type Signature
    SUCCESS 0x70[20]
    FAILURE 0x7F[21]
    IGNORED 0x7E[22]
    RECORD 0x71[23]

    Message transfer encoding

    [edit | edit source]

    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

    [edit | edit source]

    A client may send multiple messages to a server, without first waiting for a response.[24] 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 RESET message.

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

    PackStream overview - version 1

    [edit | edit source]

    PackStream is a binary presentation format for the exchange of richly-typed data. It provides a syntax layer for the Bolt messaging protocol.

    Data encoding

    [edit | edit source]

    Bolt supports encoding for a number of different data types.

    Type Description
    Null[25] Represents the absence of a value.
    Boolean[26] Boolean true or false.
    Integer[27] 64-bit signed integer.
    Float[28] 64-bit floating point number.
    Bytes[29] Byte array.
    String[30] UTF-8 encoded string.
    List[31] Ordered collection of values.
    Dictionary[32] Collection of key-value entries (no order guaranteed).
    Structure[33] Composite value with a type signature.

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    8. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    9. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    11. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    12. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    13. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    14. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    15. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    16. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    17. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    18. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    19. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    20. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    21. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    22. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    23. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    24. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    25. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    26. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    27. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    28. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    29. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    30. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    31. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    32. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    33. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    [edit | edit source]