0
votes

I'm trying to use py2neo to query a Neo4J database. I can create a graph object to connect to the database, but when I try to run a query, I get an error:

py2neo.packages.neo4j.v1.exceptions.ProtocolError: Server responded HTTP. Make sure you are not trying to connect to the http endpoint (HTTP defaults to port 7474 whereas BOLT defaults to port 7687)

I'm not sure if there's an issue with the server set up or if I'm just missing some parameter I need to set to get everything working.

Here's the code I'm using:

from py2neo import Graph

graph = Graph("bolt://bolt.bump.dev.stratified:80", auth=("neo4j", "bump"), bolt=True)
data = graph.run("MATCH p=()-[r:ACTED_IN]->() RETURN p LIMIT 25").data()

FWIW, I've also tried

graph = Graph("bolt://bolt.bump.dev.stratified:7687", auth=("neo4j", "bump"), bolt=True)
data = graph.run("MATCH p=()-[r:ACTED_IN]->() RETURN p LIMIT 25").data()

And here's the full error message (received for either port):

Traceback (most recent call last): File "/Users/amf111/anaconda3/envs/baily/lib/python3.6/site-packages/py2neo/packages/neo4j/v1/session.py", line 124, in session session = self.session_pool.pop() IndexError: pop from an empty deque During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/amf111/anaconda3/envs/baily/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2961, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in data = graph.run("MATCH p=()-[r:ACTED_IN]->() RETURN p LIMIT 25").data() File "/Users/amf111/anaconda3/envs/baily/lib/python3.6/site-packages/py2neo/database/init.py", line 731, in run return self.begin(autocommit=True).run(statement, parameters, **kwparameters) File "/Users/amf111/anaconda3/envs/baily/lib/python3.6/site-packages/py2neo/database/init.py", line 370, in begin return self.transaction_class(self, autocommit) File "/Users/amf111/anaconda3/envs/baily/lib/python3.6/site-packages/py2neo/database/init.py", line 1249, in init self.session = driver.session() File "/Users/amf111/anaconda3/envs/baily/lib/python3.6/site-packages/py2neo/packages/neo4j/v1/session.py", line 126, in session connection = connect(self.address, self.ssl_context, **self.config) File "/Users/amf111/anaconda3/envs/baily/lib/python3.6/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 486, in connect "(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)") py2neo.packages.neo4j.v1.exceptions.ProtocolError: Server responded HTTP. Make sure you are not trying to connect to the http endpoint (HTTP defaults to port 7474 whereas BOLT defaults to port 7687)

1

1 Answers

0
votes

The error is clear in the message, the default bolt port is 7687 unless you modify the neo4j.conf file.

Try changing the port 80 to 7687 and try

graph = Graph("bolt://bolt.bump.dev.stratified:7687", auth=("neo4j", "bump"), bolt=True)