neo4j / neo4j-python-driver

Neo4j Bolt driver for Python
https://neo4j.com/docs/api/python-driver/current/
Other
898 stars 186 forks source link

"Unable to retrieve routing information" #948

Closed SaiChaitanya13 closed 1 year ago

SaiChaitanya13 commented 1 year ago

Hi I have been trying to connect to the database I have created via Python. I have tried py2neo as well as neo4j Python driver. However, I am unable to connect even with the right credentials.

from neo4j import GraphDatabase class Neo4jConnection:

def __init__(self, uri, user, pwd):
    self.__uri = uri
    self.__user = user
    self.__pwd = pwd
    self.__driver = None
    try:
        self.__driver = GraphDatabase.driver(self.__uri, auth=(self.__user, self.__pwd))
    except Exception as e:
        print("Failed to create the driver:", e)

def close(self):
    if self.__driver is not None:
        self.__driver.close()

def query(self, query, db=None):
    assert self.__driver is not None, "Driver not initialized!"
    session = None
    response = None
    try: 
        session = self.__driver.session(database=db) if db is not None else self.__driver.session() 
        response = list(session.run(query))
    except Exception as e:
        print("Query failed:", e)
    finally: 
        if session is not None:
            session.close()
    return response

conn = Neo4jConnection(uri="neo4j+s://xxxx.databases.neo4j.io", user="neo4j", pwd= "xxx")

conn.query("xxx")

For example when using this, I get this error "ERROR:neo4j:Unable to retrieve routing information Query failed: Unable to retrieve routing information"

from neo4j import GraphDatabase URI = "neo4j+s:// xxxx.databases.neo4j.io" AUTH = ("neo4j", ":xxx")

with GraphDatabase.driver(URI, auth=AUTH) as driver: driver.verify_connectivity() I get this error when running this. ERROR:neo4j:Unable to retrieve routing information.

Could you please help me with this? Thank you

SaiChaitanya13 commented 1 year ago

It's okay thank you! I realised the issue was the restrictions of the wifi of my company. It works perfectly when connected to my own phone's hotspot. Thank you and sorry for the inconvenience!