cancel
Showing results for 
Search instead for 
Did you mean: 

C# Driver Exception : Failed to acquire a connection from connection pool

We are using the .net driver to connect Neo4j AURA DB hosted on the Neo4j cloud. After some time of connectivity, we are getting below exception from the driver.

Neo4j.Driver.ClientException: Failed to acquire a connection from connection pool for server with URI `'' as this server has already been removed from routing table. Please retry your query again and you should be routed with a different server from the new routing table. You should not see this error persistently.

Below is the code used to create the driver and the multiple driver instances are used in the application.

GraphDatabase.Driver(_serverUrl, AuthTokens.Basic(_username, _password), o =>
{
 o.WithSocketKeepAliveEnabled(true)
.WithMaxConnectionLifetime(TimeSpan.MaxValue);
});

 

1 REPLY 1

grant_lodge
Neo4j
Neo4j

Hello, As aura is a dynamic environment your instances can be upgraded or moved to a new machine etc, you can't rely on the connections to stay alive indefinitely.

This error should only be seen if using Session.Run/RunAsync to issue queries.

Best practices when working with Aura are to use:
Session.ReadTransactionAsync(Driver v4.X) /Session.ExecuteReadAsync(Driver v5+) Session.WriteTransactionAsync(Driver v4.X)/Session.ExecuteWriteAsync(Driver v5+).
These will attempt to handle the update of a routing table without propagating an error to a user.