Aura, being a fully managed service, is designed to automatically recover from failure and to be upgraded and patched behind the scenes, with no input from the user. This means that leadership elections in the clusters running Aura happen frequently, often resulting in driver errors due to losing connection to the cluster member the driver was using as the leader. The Neo4j drivers have a number of configuration settings that can be tweaked to accommodate these features. This includes setting values governing retries and timeouts. This article will detail these settings specifically for the Java driver.
In all cases, make sure you're making use of transaction functions when running queries on Aura.
There are two settings for the Java driver that will help your application automatically recover from any unexpected losses of connection: .withMaxConnectionLifetime() and .withConnectionLivenessCheckTimeout() . Both of these are set using the Config.ConfigBuilder interface so your connection would look like this:
Driver driver = GraphDatabase.driver(neo4jUri),
AuthTokens.basic(username, password),
org.neo4j.driver.Config.builder()
.withMaxConnectionLifetime(8, TimeUnit.MINUTES)
.withConnectionLivenessCheckTimeout(2, TimeUnit.MINUTES).build()
Remember to use a "neo4j+s://" connection schema when connecting to Aura to ensure your connection is encrypted.
If you are still seeing frequent disconnect errors after using these settings and ensuring your application is using transaction functions, please open a ticket using the blue button below and one of our Support engineers will assist you.
Comments
0 comments
Please sign in to leave a comment.