cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to check if driver connected to neo4j on startup?

Hello,

Was wondering if there was a way to check to see if the driver connected to the neo4j server when the driver was initialized, that way I can throw an error or panic when the application cannot connect to the server.

Thanks,
Matt

  • Go
2 REPLIES 2

Hi @MattJBrowning,

The driver behaves in a lazy way and do not actually establish any connection on construction. The actual first contact is performed when one of session.Run, session.BeginTransaction, session.ReadTransaction or session.WriteTransaction is invoked.

As a solution, you can write your own function to test connectivity using a very simple query, like RETURN 1.

I will also add a feature request regarding this functionality (something like driver.Verify() returning an error).

Thanks.

This is an old question but there is now an official VerifyConnectivity function in the Driver interface.