JavaScript driver version 4.4.5 and greater assumes database connectivity. When connection fails, the two most common error messages are a routing table error, or, “Session Expired.” To avoid such occurrences, verify connectivity before creating a session object, and specify the default database in your driver definition.
Errors:
- Neo4jError: Could not perform discovery. No routing servers available. Known routing table: RoutingTable[database=default database, expirationTime=0, currentTime=1644933316983, routers=[], readers=[], writers=[]]
- Session Expired
Causes:
- Unable to connect to the database.
- No default database defined.
Solutions:
- Specify the default database.
- driver.verifyConnectivity()
- Avoid exceeding max_connections.
When connecting, the driver needs to go through a discovery process for the default database. This discovery can timeout, leading to one of the error messages above. The discovery process can be bypassed by specifying the default database in the driver definition. Instead of using driver.session() without specifying the database to use do the following, driver.session({ database: "neo4j" }). This way, you bypass the routing table lookup.
To further reduce the possibility of seeing these errors you should verify the connection using the verifyConnectivity driver method.
const session = driver.session({ database: "neo4j" })
driver.verifyConnectivity()
let session = driver.session(....)
Lastly, rapid session creation can exceed the database’s maximum concurrent connection limit, resulting in the, “Session Expired,” error when creating more sessions.
Comments
0 comments
Please sign in to leave a comment.