0

I am using Py2neo package to query my database which is located in a server machine.

My code snippet:

from py2neo import Graph,authenticate
import time
from py2neo.packages.httpstream import http
http.socket_timeout = 9999


    def dbConnect():
        graph = Graph("http://192.xxx.xxx.xxx:7473/root/neo4j.graphdb")
        print(graph)

        #execute a cypher query
        cypher()

        return 

    def cypher():
        start_time = time.time()
        result = graph.cypher.execute("MATCH (n) RETURN COUNT(n)")
        print(time.time - start_time)
        return 

    if __name__ == '__main__':
        dbConnect()

Unable to fetch data from the machine, in turn returning with a error,

Error Message:

<Graph uri=u'http://192.168.204.146:7473/root/neo4j.graphdb/'>
Traceback (most recent call last):
  File "D:\Innominds\Collective[I]\Dev\Graph\Cypher_VS_Api.py", line 30, in <module>
    dbConnect()
  File "D:\Innominds\Collective[I]\Dev\Graph\Cypher_VS_Api.py", line 19, in dbConnect
    cypher()
  File "D:\Innominds\Collective[I]\Dev\Graph\Cypher_VS_Api.py", line 25, in cypher
    result = graph.cypher.execute("MATCH (n) RETURN COUNT(n)")
  File "C:\Python27\lib\site-packages\py2neo\core.py", line 661, in cypher
    metadata = self.resource.metadata
  File "C:\Python27\lib\site-packages\py2neo\core.py", line 213, in metadata
    self.get()
  File "C:\Python27\lib\site-packages\py2neo\core.py", line 258, in get
    response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
  File "C:\Python27\lib\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 "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 943, in __get_or_head
    return rq.submit(redirect_limit=redirect_limit, **kwargs)
  File "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 433, in submit
    http, rs = submit(self.method, uri, self.body, self.headers)
  File "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 325, in submit
    response = send("peer closed connection")
  File "C:\Python27\lib\site-packages\py2neo\packages\httpstream\http.py", line 318, in send
    return http.getresponse(**getresponse_args)
  File "C:\Python27\lib\httplib.py", line 1074, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 415, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 379, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''

Observe, the first line in the error message just a print statement in the code, which is printing the graph object to the console. And, http import is a googled knowledge.

What are the required setting and changes to be made in order to access the graph database in the server machine from my local machine.

Jack Daniel
  • 2,527
  • 3
  • 31
  • 52

1 Answers1

0

First you should check if your server is accessible and if you can open the web interface in a browser.

You connect to http with the standard https port 7473 and the URL looks wrong.

http://192.xxx.xxx.xxx:7473/root/neo4j.graphdb

You should try to connect with http to 7474 or https to 7473. And the graph URL should look like http://server:port/db/data. Try:

http://192.xxx.xxx.xxx:7474/db/data
https://192.xxx.xxx.xxx:7473/db/data

Also you don't use authentication. Have you disabled it on the server?

Martin Preusse
  • 9,151
  • 12
  • 48
  • 80