py2neo bolt ProtocolError:服务器关闭连接

时间:2017-03-31 02:21:30

标签: neo4j py2neo

我们看到错误的间歇性故障py2neo.packages.neo4j.v1.exceptions.ProtocolError:服务器关闭连接(下面的堆栈跟踪)。此错误仅在执行相同的代码块时不时发生。

以下是我们使用的代码:

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)

以下是完整的异常堆栈跟踪:

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

谢谢!

1 个答案:

答案 0 :(得分:1)

有同样的问题(零星的失败)。我改变了以下内容:

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

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

如果您在不使用HTTPS或Bolt的情况下感到舒服,可以尝试一下。