Neo4j unable to connect to graph database server

[亡魂溺海] 提交于 2019-12-11 13:56:49

问题


I am using an example script to connect to the neo4j server and after that run a query. But I am getting this error:

C:\cygwin\lib\python2.7\site-packages\neo4j\v1\session.py:94: UserWarning: Bolt over TLS is only available in Python 2.7.9+ and Python 3.3+ so communications are not secure

warn("Bolt over TLS is only available in Python 2.7.9+ and Python 3.3+ "

Traceback (most recent call last): File "C:\Users\FTS.fts-gnosis\workspace\hello1\tester.py", line 3, in session = driver.session() File "C:\cygwin\lib\python2.7\site-packages\neo4j\v1\session.py", line 148, in session session = Session(self) File "C:\cygwin\lib\python2.7\site-packages\neo4j\v1\session.py", line 461, in init self.connection = connect(driver.host, driver.port, driver.ssl_context, **driver.config) File "C:\cygwin\lib\python2.7\site-packages\neo4j\v1\connection.py", line 384, in connect s = create_connection((host, port)) File "C:\Python27\lib\socket.py", line 553, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM):

socket.gaierror: [Errno 11004] getaddrinfo failed

Example code :

from neo4j.v1 import GraphDatabase, basic_auth
driver = GraphDatabase.driver("bolt://http://localhost:7474",             auth=basic_auth("neo4j", "neo"))
session = driver.session()
result = session.run("MATCH (label:OFFICER)-[r]->()  WHERE label.NAME = 'Prinza Limited' RETURN label,r")
print result
session.close()

回答1:


The driver only support Bolt, so no http possible.

Your connection uri mixes the two protocols, change to this :

driver = GraphDatabase.driver("bolt://localhost",auth=basic_auth("neo4j", "neo"))
session = driver.session()

Normally, by just following the example in the repository readme, you shouldn't have the http in the connection uri : https://github.com/neo4j/neo4j-python-driver#example-usage



来源:https://stackoverflow.com/questions/37697695/neo4j-unable-to-connect-to-graph-database-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!