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
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
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.