2015-09-25 87 views
0

我試圖跟隨this neo4j教程,我遇到連接到API的問題。這裏是我的回溯:python py2neo SocketError:拒絕連接

>>> graph.delete_all() 

Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
File "/usr/local/lib/python2.7/site-packages/py2neo/core.py", line 748, in  delete_all 
statement = StartOrMatch(self).relationship("r", "*").string + "DELETE r" 
File "/usr/local/lib/python2.7/site-packages/py2neo/cypher/util.py", line 45, in string 
if self.graph.supports_start_clause: 
File "/usr/local/lib/python2.7/site-packages/py2neo/core.py", line 1105, in supports_start_clause 
return self.neo4j_version < (2, 2) 
File "/usr/local/lib/python2.7/site-packages/py2neo/core.py", line 964, in neo4j_version 
return version_tuple(self.resource.metadata["neo4j_version"]) 
File "/usr/local/lib/python2.7/site-packages/py2neo/core.py", line 213, in metadata 
self.get() 
File "/usr/local/lib/python2.7/site-packages/py2neo/core.py", line 258, in get 
response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs) 
File "/usr/local/lib/python2.7/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 "/usr/local/lib/python2.7/site-packages/py2neo/packages/httpstream/http.py", line 943, in __get_or_head 
return rq.submit(redirect_limit=redirect_limit, **kwargs) 
File "/usr/local/lib/python2.7/site-packages/py2neo/packages/httpstream/http.py", line 433, in submit 
http, rs = submit(self.method, uri, self.body, self.headers) 
File "/usr/local/lib/python2.7/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 

我是新來的網絡/套接字連接,所以這是怎麼回事的人類可讀的解釋是非常有幫助的。

回答

1

您不會顯示您的連接代碼(Graph構造函數)或提及您的設置,但是此錯誤的常見原因是(1)服務器未運行,(2)客戶端連接到錯誤的機器或端口或(3)客戶端和服務器之間存在防火牆,阻止訪問。

我建議你嘗試使用cURL或類似的工具從命令行連接到服務器,然後確保你的Python代碼連接到相同的位置。

1

我有這個錯誤,因爲我指定了.properties文件中的IP地址,但我使用本地主機來連接。一旦我在兩個地方使用了IP地址,它就可以工作。

在/etc/neo4j/neo4j-server.properties

org.neo4j.server.webserver.address = 1.2.3.4

API URL:

http://neo4j:[email protected]:7474/db/data/