hey i am trying to connecto to neo4j , but its throwing error
RISHABH SHANDILYA
S: <CONNECTION FAILED> BoltSecurityError: [SSLCertVerificationError] Connection Failed. Please ensure that your database is listening on the correct host and port and that you have enabled encryption if required. Note that the default encryption setting has changed in Neo4j 4.0. See the docs for more information. Failed to establish encrypted connection. (code 1: Operation not permitted)
DEBUG:neo4j.pool:[#0000] _: <POOL> deactivating address ResolvedIPv4Address(('34.126.64.110', 7687))
DEBUG:neo4j.pool:[#0000] _: <POOL> table={None: RoutingTable(database=None routers={IPv4Address(('9e86f0c0.databases.neo4j.io', 7687))}, readers={}, writers={}, last_updated_time=517723.375, ttl=0)}
DEBUG:neo4j.pool:[#0000] _: <POOL> failed to fetch routing info from ResolvedIPv4Address(('34.126.64.110', 7687))
DEBUG:neo4j.pool:[#0000] _: <POOL> deactivating address IPv4Address(('9e86f0c0.databases.neo4j.io', 7687))
DEBUG:neo4j.pool:[#0000] _: <POOL> table={None: RoutingTable(database=None routers={}, readers={}, writers={}, last_updated_time=517723.375, ttl=0)}
ERROR:neo4j.pool:Unable to retrieve routing information
Traceback (most recent call last):
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\langchain_community\graphs\neo4j_graph.py", line 350, in __init__
self._driver.verify_connectivity()
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\neo4j\_sync\driver.py", line 1067, in verify_connectivity
self._get_server_info(session_config)
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\neo4j\_sync\driver.py", line 1281, in _get_server_info
return session._get_server_info()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\neo4j\_sync\work\session.py", line 172, in _get_server_info
self._connect(READ_ACCESS, liveness_check_timeout=0)
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\neo4j\_sync\work\session.py", line 130, in _connect
super()._connect(
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\neo4j\_sync\work\workspace.py", line 165, in _connect
self._pool.update_routing_table(
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\neo4j\_sync\io\_pool.py", line 802, in update_routing_table
raise ServiceUnavailable("Unable to retrieve routing information")
neo4j.exceptions.ServiceUnavailable: Unable to retrieve routing information
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\server.py", line 3, in <module>
app = create_app()
^^^^^^^^^^^^
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\app.py", line 31, in create_app
from api.urls import register_routes
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\api\urls.py", line 5, in <module>
from api.handlers.query.querymodel import chat,retrieve_chat
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\api\handlers\query\querymodel.py", line 17, in <module>
graph = Neo4jGraph()
^^^^^^^^^^^^
File "C:\Users\lenovo\OneDrive\Desktop\hctober_2nd_try\devhub\server\venv\Lib\site-packages\langchain_community\graphs\neo4j_graph.py", line 352, in __init__
raise ValueError(
ValueError: Could not connect to Neo4j database. Please ensure that the url is correct
DEBUG:neo4j.pool:[#0000] _: <POOL> close
DEBUG:neo4j.pool:[#0000] _: <POOL> close
DEBUG:neo4j.pool:[#0000] _: <POOL> close
jon.giffard@neo4j.com
Can you post a code snippet that shows the db connection information ? If you're using our Python driver it will look something like
URI = "<URI for Neo4j database>"
AUTH = ("<Username>", "<Password>")
with GraphDatabase.driver(URI, auth=AUTH) as driver:
driver.verify_connectivity()
print("Connection established.")
RISHABH SHANDILYA
jon.giffard@neo4j.com
thanks for your quick response ,
this is a open source project , so i just started with neo4j , but i think
this is the file
extensions.py
from flask_bcrypt import Bcrypt
from flask_cors import CORS
from neo4j import GraphDatabase
from config import Config
bcrypt = Bcrypt()
cors = CORS()
class Neo4jDriver:
def __init__(self, uri, user, password):
self.driver = GraphDatabase.driver(uri, auth=(user, password))
def close(self):
self.driver.close()
neo4j_db = Neo4jDriver(
uri=Config.NEO4J_URI,
user=Config.NEO4J_USER,
password=Config.NEO4J_PASSWORD
)
////////
and this is my config.py file
////////
import os
from dotenv import load_dotenv
load_dotenv()
class Config:
SECRET_KEY = os.getenv('SECRET_KEY')
NEO4J_URI = os.getenv('NEO4J_URI')
NEO4J_USER = os.getenv('NEO4J_USER')
NEO4J_PASSWORD = os.getenv('NEO4J_PASSWORD')
/////////
app.py file
//////////
def create_app():
app = Flask(__name__)
app.config.from_object(Config)
@app.route('/')
Initialize Neo4j
global neo4j_db
neo4j_db = Neo4jDriver(
app.config['NEO4J_URI'],
app.config['NEO4J_USER'],
app.config['NEO4J_PASSWORD']
)
Initialize other extensions
bcrypt.init_app(app)
cors.init_app(app, supports_credentials=True, resources={
r"/*": {
"origins": ["http://localhost:5173", "https://devhub-ai.vercel.app"],
"methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
"allow_headers": ["Content-Type", "Authorization"]
}
})
logging.basicConfig(level=logging.DEBUG)
with app.app_context():
from api.urls import register_routes
register_routes(app)
@app.teardown_appcontext
def close_neo4j(exception):
neo4j_db.close()
return app
jon.giffard@neo4j.com
RISHABH SHANDILYA Whats the value of NEO4J_URI = os.getenv('NEO4J_URI') ?
RISHABH SHANDILYA
jon.giffard@neo4j.com
this is what the maintainer provided
neo4j+s://60da3df5.databases.neo4j.io
i also tried by creating my own one
neo4j+s://9e86f0c0.databases.neo4j.io
none of them worked
jon.giffard@neo4j.com
RISHABH SHANDILYA .could you send me ( jon.giffard@neo4j.com )
github repo where this code came from
if possible, the URI , user and password for the DB.
This will alllow me to run the code and see what's going on.
jon.giffard@neo4j.com
RISHABH SHANDILYA .I just tried to login using the browser interface and it's not letting me due to too many failed attempts :(
I'll try again in tomorrow - I'm in the U.k and it's getting a bit late now.
Do you have an email address to use? It will be easier than swapping comments over this forum.
I;ve made a note of the connection details so i've removed your post with them to avoid any potential harm.
RISHABH SHANDILYA
jon.giffard@neo4j.com
sure thanks for looking into this issue, hope it will be solved soon
mail_id---
shandilya.rishabh117@gmail.com
jon.giffard@neo4j.com
RISHABH SHANDILYA .After cloning the repo and trying to run the code, there was an entry missing from the .env file - NEO4J_USERNAME Putting the entry in allowed me to run server.py and establish a connection to Neo4j
- in the server folder, create an .env file with the following contents and add your values after the =
GOOGLE_API_KEY=
SECRET_KEY=
NEO4J_URI=neo4j+s://60da3df5.databases.neo4j.io
NEO4J_USER=neo4j
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=
If you then run server.py, you will see that a connection is established to Neo4j.
Best of luck with what you're working on.