Skip to content

Commit 35d6911

Browse files
author
Zhen
committed
Add magic start bytes
1 parent ca792db commit 35d6911

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

neo4j/v1/connection.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
DEFAULT_PORT = 7687
3939
DEFAULT_USER_AGENT = "neo4j-python/%s" % version
4040

41+
MAGIC_PREAMBLE = 0x6060B017
42+
4143
# Signature bytes for each message type
4244
INIT = b"\x01" # 0000 0001 // INIT <user_agent>
4345
ACK_FAILURE = b"\x0F" # 0000 1111 // ACK_FAILURE
@@ -306,8 +308,9 @@ def connect(host, port=None, **config):
306308

307309
# Send details of the protocol versions supported
308310
supported_versions = [1, 0, 0, 0]
309-
if __debug__: log_info("C: [HANDSHAKE] %r", supported_versions)
310-
data = b"".join(struct_pack(">I", version) for version in supported_versions)
311+
handshake = [MAGIC_PREAMBLE] + supported_versions
312+
if __debug__: log_info("C: [HANDSHAKE] 0x%X %r", MAGIC_PREAMBLE, supported_versions)
313+
data = b"".join(struct_pack(">I", num) for num in handshake)
311314
if __debug__: log_debug("C: %s", ":".join(map(hex2, data)))
312315
s.sendall(data)
313316

0 commit comments

Comments
 (0)