Hi there,
I am running a Neo4j Cloud VM instance of version: 3.4.12 (Enterprise).
I am facing an error when I attempt to connect to my Neo4j database via 'Bolt' protocol through py2neo v4.2 (I am building a web app that uses a Python-Flask backend server that connects with my Neo4j instance).
For example, to establish a connection, I run the following command:
from py2neo import Graph
Graph("bolt://mydomain.com:7687", auth=(NEO4J_USERNAME, NEO4J_PASSWORD), scheme='bolt', secure=True)
Do note that I have a custom domain attached to my server IP and I've followed the tutorial to set up an SSL certificate using LetsEncrypt following the guide at: Getting Certificates for Neo4j with LetsEncrypt | by David Allen | Neo4j Developer Blog | Medium
My Python Flask server is running locally at the moment, without an SSL cert.
The command results in the following error:
Traceback (most recent call last):
File "/venv/lib/python3.4/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/venv/lib/python3.4/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/venv/lib/python3.4/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/venv/lib/python3.4/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "venv/lib/python3.4/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/venv/lib/python3.4/site-packages/flask/_compat.py", line 34, in reraise
raise value.with_traceback(tb)
File "/venv/lib/python3.4/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/venv/lib/python3.4/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/venv/lib/python3.4/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/venv/lib/python3.4/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/venv/lib/python3.4/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/venv/lib/python3.4/site-packages/flask/_compat.py", line 34, in reraise
raise value.with_traceback(tb)
File "/venv/lib/python3.4/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/venv/lib/python3.4/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/venv/lib/python3.4/site-packages/flask_restful/__init__.py", line 458, in wrapper
resp = resource(*args, **kwargs)
File "/venv/lib/python3.4/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/venv/lib/python3.4/site-packages/flask_restful/__init__.py", line 573, in dispatch_request
resp = meth(*args, **kwargs)
File "/venv/lib/python3.4/site-packages/flask_httpauth.py", line 104, in decorated
return f(*args, **kwargs)
File "/resources/base.py", line 20, in get
data = graph.run(query).data()
File "venv/lib/python3.4/site-packages/py2neo/database.py", line 526, in run
return self.begin(autocommit=True).run(cypher, parameters, **kwparameters)
File "/venv/lib/python3.4/site-packages/py2neo/database.py", line 805, in run
entities=entities))
File "/venv/lib/python3.4/site-packages/py2neo/internal/connectors.py", line 285, in run
return self._run_1(statement, parameters, graph, keys, entities)
File "/venv/lib/python3.4/site-packages/py2neo/internal/connectors.py", line 234, in _run_1
cx = self.pool.acquire()
File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 711, in acquire
return self.acquire_direct(self.address)
File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 604, in acquire_direct
connection = self.connector(address, error_handler=self.connection_error_handler)
File "/venv/lib/python3.4/site-packages/py2neo/internal/connectors.py", line 225, in connector
return connect(address_, auth=cx_data["auth"], **kwargs)
File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 967, in connect
raise last_error
File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 959, in connect
connection = _handshake(s, resolved_address, der_encoded_server_certificate, **config)
File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 905, in _handshake
raise ServiceUnavailable("Connection to %r closed without handshake response" % (resolved_address,))
neobolt.exceptions.ServiceUnavailable: Connection to (*IP_ADDRESS*, 7687) closed without handshake response
In Chrome, I am able to use Neo4j Browser at "https://mydomain.com:7473" and log in successfully to "bolt://mydomain.com:7687".
To circumvent the problem, I run an HTTP connection and it works. For example:
from py2neo import Graph
Graph("http://mydomain.com:7474", auth=(NEO4J_USERNAME, NEO4J_PASSWORD))
Any help will be greatly appreciated! I would be happy to provide any necessary information.
Cheers!