Search code examples
neo4jpy2neo

py2neo 3.1.2 connection problems


I am trying to commit a small graph of three nodes (a_py2neo_subgraph) to my graphene Neo4j server. I am using py2neo 3.1.2.

g = py2neo.Graph(server)
tx = g.begin()
tx.create(a_py2neo_subgraph)
tx.commit()
tx.finished()

Where "server" is the exact value given by Graphene (i.e. something like http://nick:password@hobby-hash.dbs.graphenedb.com:port/db/data/). In order to debug, I ran with py2neo watch and this was the info given by watch for my httpstream:

> GET server
< 200 OK [1287]

Then I get the following traceback:

Traceback (most recent call last):
  File "C:/Users/petr.svarny/PycharmProjects/untitled/test.py", line 116, in <module>
    tx = g.begin()
  File "C:\Users\petr.svarny\untitled\lib\site-packages\py2neo\database\__init__.py", line 370, in begin
    return self.transaction_class(self, autocommit)
  File "C:\Users\petr.svarny\untitled\lib\site-packages\py2neo\database\__init__.py", line 1249, in __init__
    self.session = driver.session()
  File "C:\Users\petr.svarny\untitled\lib\site-packages\py2neo\packages\neo4j\v1\session.py", line 126, in session
    connection = connect(self.address, self.ssl_context, **self.config)
  File "C:\Users\petr.svarny\untitled\lib\site-packages\py2neo\packages\neo4j\v1\bolt.py", line 419, in connect
    s = create_connection(host_port)
  File "C:\Python27\Lib\socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 10060]

I already tried to set the socket timeout to 9999, did not help. I attempted to connect via telnet to the server and managed to do so without any problem. Similarly I am able to access the server address when I enter it into my browser. I also managed to run my code for a local Neo4j database.

Thank you for any suggestions.


Solution

  • I'm Judit from GrapheneDB. Can you check which version of py2neo are you using? The problem you have described looks like a common issue when moving from Py2neo v2 to v3. Since py2neo v3 supports Bolt protocol, you have to specify the bolt port or just tell the driver you're not using it.

    If you don't want to use Bolt connection, your code should look like the following:

    graph = Graph("http://USER:PASS@hobby-hash.dbs.graphenedb.com:port/db/data/", bolt = False)

    If it's not your case, it'd be useful to know which version of Python/Py2neo/Neo4j are you using.

    Cheers!