neo4j-contrib / py2neo

EOL! Py2neo is a comprehensive Neo4j driver library and toolkit for Python.
https://py2neo.org
Apache License 2.0
20 stars 8 forks source link

"ConnectionResetError: [Errno 104] Connection reset by peer" after idle connection #934

Open gqh1995 opened 2 years ago

gqh1995 commented 2 years ago

I established a long connection between client and neo4j using py2neo 2021.1.5, and raise this error after idle connection. error infos: Traceback (most recent call last): File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/wiring.py", line 117, in read received = self.__socket.recv(requested) ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/bolt.py", line 87, in read_message hi, lo = self.wire.read(2) File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/wiring.py", line 119, in read self.__mark_broken("Wire broken") File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/wiring.py", line 222, in __mark_broken bytes_received=self.__bytes_received) py2neo.wiring.BrokenWireError: Wire broken after 0.0s idle (3514 bytes sent, 6855 bytes received)

The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/opt/bin/knowledge_graph/routes/graph/views.py", line 168, in click_node datas = og.clicknode(nodeinfo, rtype) File "/opt/bin/knowledge_graph/algo/graph/graph_operator.py", line 146, in clicknode idxs = self.search_module.get1hop(nodeinfo['id']) File "/opt/bin/knowledge_graph/algo/modules/search_module.py", line 91, in get1hop "match (n)-[r]-(m) return id(r)".format(idx)) File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/database.py", line 405, in run return self.auto().run(cypher, parameters, **kwparameters) File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/database.py", line 980, in run readonly=self.readonly) File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/__init__.py", line 1343, in auto_run cx.pull(result, n=pull) File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/bolt.py", line 527, in pull self._sync(response) File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/bolt.py", line 747, in _sync self._wait(response) File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/bolt.py", line 742, in _wait self._fetch() File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/bolt.py", line 717, in _fetch tag, fields = self.read_message() File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/bolt.py", line 644, in read_message tag, fields = self._reader.read_message() File "/opt/conda/envs/knowledge-graph/lib/python3.7/site-packages/py2neo/client/bolt.py", line 89, in read_message raise_from(ConnectionBroken("Failed to read message"), error) File "<string>", line 3, in raise_from py2neo.errors.ConnectionBroken: Failed to read message

Although it does not affect the use but will often report errors, What can I do to prevent the code from reporting errors? Looking forward to your reply!

gqh1995 commented 2 years ago

This error can occur when querying any data. eg, this happened when i use this query: self.g.run("match (n) where id(n)={0} with n match (n)-[r]-(m) return id(r)".format(idx))

chrisammon3000 commented 2 years ago

I encountered this error running a long query using just the requests module using the HTTP connector for Neo4j 4.4, so it may a problem with Neo4j or the server configuration and not py2neo. It happened while loading a series of large CSVs. I fixed it by running the queries on the server itself.

philastrophist commented 2 years ago

I'm also experiencing this still on server side. I am submitting multiple v. big queries and it seems to happen randomly (maybe because I'm close to the timeout. Is there a way to adjust the timeout, even so I can debug it? The neo4j debug.log tells me this:

022-05-13 09:45:54.520+0000 WARN  [o.n.k.i.c.VmPauseMonitorComponent] Detected VM stop-the-world pause: {pauseTime=335, gcTime=494, gcCount=1}
2022-05-13 09:45:55.878+0000 WARN  [o.n.k.i.c.VmPauseMonitorComponent] Detected VM stop-the-world pause: {pauseTime=357, gcTime=532, gcCount=1}
2022-05-13 09:46:03.682+0000 WARN  [o.n.k.i.c.VmPauseMonitorComponent] Detected VM stop-the-world pause: {pauseTime=241, gcTime=307, gcCount=1}
2022-05-13 09:48:21.209+0000 WARN  [o.n.b.t.p.HouseKeeper] Fatal error occurred when handling a client connection, remote peer unexpectedly closed connection: [id: 0x9a7fc565, L:/127.0.0.1:7687 - R:/127.0.0.1:36574]

Py2neo returns this message

  File "/tmp/pycharm_project_3/weaveio/graph.py", line 103, in _execute
    return self.neograph.auto(readonly=not self.write_allowed).run(cypher, parameters=parameters)
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/database.py", line 980, in run
    readonly=self.readonly)
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/client/__init__.py", line 1343, in auto_run
    cx.pull(result, n=pull)
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/client/bolt.py", line 943, in pull
    self._sync(response)
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/client/bolt.py", line 747, in _sync
    self._wait(response)
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/client/bolt.py", line 742, in _wait
    self._fetch()
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/client/bolt.py", line 717, in _fetch
    tag, fields = self.read_message()
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/client/bolt.py", line 644, in read_message
    tag, fields = self._reader.read_message()
  File "/home/sread/miniconda2/envs/weaveio/lib/python3.7/site-packages/py2neo/client/bolt.py", line 96, in read_message
    _, n = divmod(message[0], 0x10)
IndexError: index out of range

To me it looks like my error is related to the above problems people are having and that indexerror seems to be a symptom of an unhandled empty response if I guess correctly.

referenced in #944