首页 > 解决方案 > NEO4J 底层套接字连接消失 (_ssl.c:2084)

问题描述

  1. 我已经安装了neo4j-driver 1.7.5
  2. 我设置了Neo4J 因果集群
  3. 尝试在 Python 中开始编码以连接到它。(我知道它的螺栓+路由,但现在使用默认代码)

代码

# REF https://pypi.org/project/neo4j-driver/
from neo4j import GraphDatabase

driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "password"))

def add_friend(tx, name, friend_name):
    tx.run("MERGE (a:Person {name: $name}) "
           "MERGE (a)-[:KNOWS]->(friend:Person {name: $friend_name})",
           name=name, friend_name=friend_name)

def print_friends(tx, name):
    for record in tx.run("MATCH (a:Person)-[:KNOWS]->(friend) WHERE a.name = $name "
                         "RETURN friend.name ORDER BY friend.name", name=name):
        print(record["friend.name"])

with driver.session() as session:
    session.write_transaction(add_friend, "Arthur", "Guinevere")
    session.write_transaction(add_friend, "Arthur", "Lancelot")
    session.write_transaction(add_friend, "Arthur", "Merlin")
    session.read_transaction(print_friends, "Arthur")

输出

Guinevere
Lancelot
Merlin
Failed to write data to connection Address(host='localhost', port=7687) (Address(host='127.0.0.1', port=7687)); ("0; 'Underlying socket connection gone (_ssl.c:2084)'")
Failed to write data to connection Address(host='localhost', port=7687) (Address(host='127.0.0.1', port=7687)); ("0; 'Underlying socket connection gone (_ssl.c:2084)'")

如果我在最后添加这个

driver.close()

然后我没有得到套接字消失的错误。

标签: pythonneo4jcypher

解决方案


我已经通过以下命令解决了这个问题

pip install --force-reinstall neo4j==1.7.2 neobolt==1.7.9 neotime==1.7.4

https://github.com/neo4j/neo4j-python-driver/issues/293


推荐阅读