Could not perform discovery for database

We are able to connect to the db regularly using browser, cypher-shell, or a java driver. However, sometimes, when we run a query, we get the error Could not perform discovery for database in our java quarkus backend. It is hard to reproduce.

What is the best approach to prevent this? Should we create a new driver instance or should we use the current driver to get a new session?

In your Java application you should create one driver at startup and use it through out. You should create a new session from the driver each time you want to query. You can execute and process your query with transaction functions from the session.

What version of server and driver are you using? What is your driver url?

Hi, thank you for response.
We create a single driver, each time we want to run a query, we use driver.session() in order to create a new session like you said. We catch SessionExpiredException, and we make a recursive call to our runQuery helper method in order to get a new session. However, ServiceUnavailableException is thrown when we get the error Could not perform discovery for database. What should be logic when we get ServiceUnavailableException? We are planning to make another recursive call to runQuery to get a new session.

The driver version is 5.17.0.
The URL starts with neo4j+s://, but my connector seems as "bolt"
Neo4j version is 5

Memory 2GB

Storage 4GB

CPU 1

The CPU, memory,network, and storage utilizations are idle during those exceptions. We do not have lots of data at the time.

Are you connecting to a cluster or a single instance server? If the later, can you try the //bolt+s connection scheme? This may eliminate the routing issues, as the bolt scheme doesn’t use routing.

We are using single instance server. The URL that the driver uses starts with neo4j+s://, yet, when I connect to the DB using cypher-shell, I use the query CALL dbms.listConnections();. It shows that Java driver's connector is Bolt. So, what is the difference between connector being Bolt and URL starting with bolt+s:// ?. I am confused at this point.

I posted a screenshot from the documentation that describes the difference. This is my understanding bolt connects to the specific IP address provided when creating the driver. neo4j uses routing tables to route writes to a write instance in a cluster and reads to read instances in a cluster. They both are supposed to work the same in a single instance implementation.

The "+s" adds encrypted with TLS.

Yep, I see that but why my connector is shown as bolt even though I use neo4j+s:// in the link instead of bolt+s:// ?

Thank you for your support tho. We will change the protocol to bolt+s:// and monitor the situation.

the bolt+s:// and neo4j+s:// is the connection URI scheme. Maybe the "connector" in the table refers to the method of connection, which could be bolt or http.