New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Retrieve Routing information When Using Neo4j Python Driver #628
Comments
Hi, thanks for contacting us.
|
Hi @robsdedude , at our organization we are using
I increased the connection timeout connection_timeout from default (30) to 60 https://neo4j.com/docs/api/python-driver/4.3/api.html#driver-configuration but still encountering the same error , is there anything else which can be done to overcome this error neo4j version : 4.2.9 (enterprise) thanks!! |
This is really hard to debug for me as this is most certainly a network issue. The driver is telling you that the server did not respond in time. Make sure you server is running and reachable at the IP address you assume. Can you connect to the neo4j browser at I'll close this issue as it's not driver related. Feel free to follow-up here nevertheless if you think there's something else I can help you with. |
@robsdedude yes i can connect at Server is up in running (was same response from neo4j support team as well) then how come drivers are unable to connect for the rest of the 4 (any limitation at neo4j server level)? |
By default, the server can only handle (compute things for) up to 400 connections at the same time. You can change this value https://neo4j.com/docs/operations-manual/current/reference/configuration-settings/#config_dbms.connector.bolt.thread_pool_max_size . But do you have more than 400 driver-sessions executing work at the same time? Maybe you can find something helpful in the server logs. I'm just afraid I won't be of much help interpreting this, as I mostly work on the Python driver. |
Hey @robsdedude, might be naive question but when you say 400 driver-sessions , you mean 400 sessions connections (at the same time) , something like below
or is there a way at neo4j log level or server level to determine , how many connections are existing at given point of time (as you mentioned above 400 default value, want to check actual value) |
The driver opens and keeps connections open only as long as needed. So in fact neither Another idea: are you running a single server or a cluster? If it's a single server, you could try connecting to it with the Finally, sharing the whole log (you can redact IP addresses and replace your queries with dummy queries) would really make debugging this easier for me. |
@robsdedude We are running cluster. (we have 2 databases on. the server, but currently there is no transactions on 1 of the database it just has some data stored on it, and other one is actively used by the application ) ServiceUnavailable error execute_read 'cypher_query'.
For the successful one's we have logs something like below not sure if it is helpful
Please let me know if anything specific you're looking for. |
Hey @robsdedude any insight on my above logs please ? |
There is nothing in there that gives me a hint on where the problem could be. It certainly is a network issue.
|
@funkjo Did you manage to understand the source for this issue? |
Have you been able to find a concrete solution for this? I am running into the same issue. Tried all the steps described in the posts about it but the issue won't go away. A response would be much appreciated. |
I am able to get this working by using neo4j+ssc:// instead of neo4j+s. |
This suggests, that you might not have the required root CA certificate installed on your client machine. Hence, the SSL library does not trust the certificate it receives from the server. Also, note that while |
Hello. from neo4j import GraphDatabase
from utils.color import Color
import logging
import psycopg2
import json
class Connection:
# def __init__(self):
# """Initialize the database connection"""
# logging.info(f"{Color.YELLOW}Connecting to database...{Color.END}")
# def connect(self):
# """Connect to the database"""
# try:
# self.config = json.load(open("test_config.json", "r"))
# self.connection = GraphDatabase.driver(
# self.config.get("gdb").get("uri"),
# auth=(
# self.config.get("gdb").get("user"),
# self.config.get("gdb").get("password")
# )
# )
# # self.connection = psycopg2.connect(
# # host=self.config.get("db").get("host"),
# # database=self.config.get("db").get("database"),
# # user=self.config.get("db").get("user"),
# # password=self.config.get("db").get("password"),
# # )
# logging.info(f"{Color.YELLOW}Connected to database{Color.END}")
# return self.connection
# except (Exception, psycopg2.Error) as error:
# logging.error(f"{Color.RED}Error while connecting to PostgreSQL{Color.END}")
# logging.error(error)
# return
def __init__(self, uri, user, pwd):
logging.info(f"{Color.YELLOW}Connecting to database...{Color.END}")
self.__uri = uri
self.__user = user
self.__pwd = pwd
self.__driver = None
try:
self.__driver = GraphDatabase.driver(self.__uri, auth=(self.__user, self.__pwd))
logging.info(f"{Color.YELLOW}Connected to database{Color.END}")
except Exception as error:
logging.error(f"{Color.RED}Error while connecting to Neo4j{Color.END}")
logging.error(error)
def close(self):
if self.__driver is not None:
self.__driver.close()
def query(self, query, parameters=None, 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()
logging.info(query)
response = list(session.run(query))
except Exception as error:
logging.error(error)
logging.error(f"{Color.RED}Query failed{Color.END}")
finally:
if session is not None:
session.close()
return response
class Database:
def __init__(self):
"""Connect to database"""
self.config = json.load(open("test_config.json", "r"))
self.connection = Connection(
uri = self.config.get("gdb").get("uri"),
user = self.config.get("gdb").get("user"),
pwd = self.config.get("gdb").get("password"),
)
def get_knowzee_data(self):
"""Get data from knowzee table"""
block_name = []
block_short_description = []
block_long_description = []
color_comment = []
query = "Match (n:aaa) return n;"
dataset = self.connection.query(query,db="neo4j")
dataset = {
"NAME": "whether a risk is unjustifiable",
"SHORT DESCRIPTION": "Whether a risk is unjustifiable depends on if it is a gross deviation from the standard of care.",
"LONG DESCRIPTION": "In evaluating whether a risk is unjustifiable or substantial depends on whether it is a gross deviation from the standard of care.",
"PICTURES": "",
"PEOPLE": "",
"PLACES": "",
"PROFESSIONS": "",
"THINGS": "",
"TIMES": "",
"RESULTS": "",
"ACTIONS": "",
"GROUPS": "",
"CONNECTIONS": "",
"PRIORITY WITHIN GROUPS": "",
"PRIORITY FOR ALL BLOCKS": "",
"SORT ORDER": "",
"RELATED KEY WORDS": "",
"COLOR COMMENT": "Color comment for block 1"
}
for row in dataset:
block_name.append(row[0])
block_short_description.append(row[1])
block_long_description.append(row[2])
color_comment.append(row[-2])
return (
block_name,
block_short_description,
block_long_description,
color_comment,
)
def get_knowzee_metadata(self, query: str = "SELECT * FROM knowzee"):
"""Get metadata from knowzee table"""
name = []
title = []
description = []
pass and I use uri as follow. But when I run this code in docker, i get error message as this: when I run query on browser it works. |
I solved issue. |
Glad to hear you found a solution. Before I read that message, I started to skim your code and spotted that you
|
Hi @robsdedude , I'm facing a similar issue on a Neoj4 instance 5.8 (4.4 shows same behavior) deployed on a Kubernetes cluster. A python script inserts data to the database. After a certain amount of time, the insertion process suddenly starts to fail sporadically with
Below, a "bad/good-case comparison" of the debug log. Any ideas/recommendations how to fix/analyse the issue? Looking forward to receive expert feedback 😊! |
Hi @hafeja, For support I generally refer to either of
I think the online community would be the best place for this. Now I still want to give some insight of what I see in the logs:
So check your database logs and see if you can spot something interesting there. I'm not sure what conditions would lead the DBMS to respons with such an error, for that I don't know enough about the server internals. After that initial error, the driver retires the transaction because the error is classified as |
Hi @robsdedude , trying different values of However, increasing Thanks for your fast and helpful hints 👍 |
hello@robsdedude
|
This is occurring in a databricks Python notebook when using the neo4j python driver:
from neo4j import GraphDatabase
I receive the following error:Here is my code for connecting to neo4j:
This code successfully writes data to a different neo4j database when tested
The text was updated successfully, but these errors were encountered: