gpt4 book ai didi

python - py2neo SocketError : Connection refused, 但curl可以工作

转载 作者:太空宇宙 更新时间:2023-11-03 16:07:16 25 4
gpt4 key购买 nike

我正在尝试在远程 Ubuntu 服务器上设置 Flask/Neo4j 应用程序,但遇到了一个我无法解决的问题。我的应用程序使用 py2neo,但是当它尝试连接到图表时,应用程序崩溃并且 Neo4j 进程似乎停止了。我尝试过像这样在 python shell 中连接...

test = Graph('http://localhost:7474/db/data/',username='neo4j',password='myPassword')

这会失败,并且还会导致 neo4j 无法运行,直到我重新启动它。但是,这些会返回 200 响应(并且网络界面也可以工作):

curl -u neo4j http://localhost:7474/db/data/

requests.get('http://localhost:7474/db/data/', auth=('neo4j','myPassword'))

我试图提供比 this similar question 更多的信息,因为除了 py2neo 之外,连接似乎在任何地方都有效。

这是完整的回溯:

Traceback (most recent call last):
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/database/__init__.py", line 318, in __new__
inst = cls.__instances[key]
KeyError: (<class 'py2neo.database.Graph'>, <ServerAddress settings={'http_port': 7474, 'host': 'localhost'}>, 'data')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 322, in submit
response = send()
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 317, in send
http.request(xstr(method), xstr(uri.absolute_path_reference), body, headers)
File "/usr/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 80, in connect
self.source_address)
File "/usr/lib/python3.5/socket.py", line 711, in create_connection
raise err
File "/usr/lib/python3.5/socket.py", line 702, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/database/__init__.py", line 327, in __new__
use_bolt = version_tuple(inst.__remote__.get().content["neo4j_version"]) >= (3,)
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/database/http.py", line 154, in get
response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 966, in get
return self.__get_or_head("GET", if_modified_since, headers, redirect_limit, **kwargs)
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 943, in __get_or_head
return rq.submit(redirect_limit=redirect_limit, **kwargs)
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 433, in submit
http, rs = submit(self.method, uri, self.body, self.headers)
File "/home/deploy/toponimika/toponimikaenv/lib/python3.5/site-packages/py2neo/packages/httpstream/http.py", line 362, in submit
raise SocketError(code, description, host_port=uri.host_port)
py2neo.packages.httpstream.http.SocketError: Connection refused

任何我可能尝试弄清楚发生了什么的事情都会受到赞赏。

最佳答案

更改为http://用户名:密码@localhost:7474/db/data/并且它有效!

示例:

test = Graph('http://username:password@localhost:7474/db/data/')

关于python - py2neo SocketError : Connection refused, 但curl可以工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39667425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com