Our primary recommendation is to use the latest version of the official driver unless specified otherwise under certain circumstances.
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.
Read How to avoid Session Expired Error to Neo4j Aura to know more about Session Timeouts in Aura.
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(50, TimeUnit.MINUTES)
.withConnectionLivenessCheckTimeout(1, TimeUnit.MINUTES).build()
Remember to use a "neo4j+s://" connection schema when connecting to Aura to ensure your connection is encrypted.
Comments
0 comments
Please sign in to leave a comment.