Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion neo4j/v1/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,12 @@ def connect(host, port=None, ssl_context=None, **config):
if __debug__: log_info("~~ [CLOSE]")
s.shutdown(SHUT_RDWR)
s.close()
else:
elif agreed_version == 1:
return Connection(s, der_encoded_server_certificate=der_encoded_server_certificate, **config)
elif agreed_version == 1213486160:
log_error("S: [CLOSE]")
raise ProtocolError("Server responded HTTP. Make sure you are not trying to connect to the http endpoint " +
"(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)")
else:
log_error("S: [CLOSE]")
raise ProtocolError("Unknown Bolt protocol version: %d", agreed_version)
9 changes: 9 additions & 0 deletions test/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ def test_sessions_are_not_reused_if_still_in_use(self):
session_1.close()
assert session_1 is not session_2

def test_fail_nicely_when_connecting_to_http_port(self):
driver = GraphDatabase.driver("bolt://localhost:7474", auth=auth_token, encrypted=False)
with self.assertRaises(ProtocolError) as context:
driver.session()

assert str(context.exception) == "Server responded HTTP. Make sure you are not trying to connect to the http " \
"endpoint (HTTP defaults to port 7474 whereas BOLT defaults to port 7687)"



class SecurityTestCase(ServerTestCase):

Expand Down