0

We are seeing intermittent failures with the error py2neo.packages.neo4j.v1.exceptions.ProtocolError: Server closed connection (stacktrace below). This error only happens every now and again when executing the same block of code.

Here is the code we use:

graph = Graph(host=settings.NEO_4J_DB_HOST, user="username", password="password", bolt=True)
cypher_query = "MATCH path = (root)-[:subClassOf*0..]->(child) WHERE root.name = 'Some Root Name' WITH collect(DISTINCT(child.name)) AS nodes RETURN nodes"
query_result = graph.data(cypher_query)

Here is the full exception stacktrace:

File "/venv/lib/python3.5/site-packages/py2neo/database/__init__.py", line 416, in data
return self.begin(autocommit=True).run(statement, parameters, **kwparameters).data()
File "/venv/lib/python3.5/site-packages/py2neo/database/__init__.py", line 370, in begin
return self.transaction_class(self, autocommit)
File "/venv/lib/python3.5/site-packages/py2neo/database/__init__.py", line 1249, in __init__
self.session = driver.session()
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/session.py", line 126, in session
connection = connect(self.address, self.ssl_context, **self.config)
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 482, in connect
return Connection(s, der_encoded_server_certificate=der_encoded_server_certificate, **config)
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 241, in __init__
self.fetch()
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 337, in fetch
self.acknowledge_failure()
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 284, in acknowledge_failure
fetch()
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 322, in fetch
raw.writelines(self.channel.chunk_reader())
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 173, in chunk_reader
chunk_header = self._recv(2)
File "/venv/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 156, in _recv
raise ProtocolError("Server closed connection")
py2neo.packages.neo4j.v1.exceptions.ProtocolError: Server closed connection

Thank you!

1 Answers1

1

Had the same problem (sporadic failures). I've changed the following:

From

Graph(secure=True, bolt=True, ...)

To

Graph(secure=False, bolt=False, ...)

If you're comfortable without using HTTPS or Bolt, you might give it a try.

nichoio
  • 6,289
  • 4
  • 26
  • 33