How to set timeout in drivers (py2neo or neo4j)

Hi there,
I'm connecting to the neo4j sandbox using google colab. Some queries are ok, but some result in timeout error.
I want to execute a query using neo4j driver (same situation with py2neo), but it gives this error after about 45 seconds:

{code: Neo.ClientError.Transaction.TransactionTimedOut} {message: The transaction has been terminated. Retry your operation in a new transaction, and you should see a successful result. The transaction has not completed within the specified timeout (dbms.transaction.timeout). You may want to retry with a longer timeout. }

I tried using unit_of_work in two ways:

from neo4j import unit_of_work
@unit_of_work(timeout=240000) # 240,000 ms -> 240 s -> 4 mins
def execute(query):

and also


None them solved my problem.
I couldn't find any solutions for py2neo.

(I can use either of neo4j and py2neo drivers, if it is required.)
Thank you.


there are two things going on here. Firstly, duration values in Python are typically given in seconds, not milliseconds. So you set the timeout to ~2,7 days. But that doesn't explain why the transaction still gets terminated that soon. As far as I'm aware, the server doesn't allow the client to increase the configured timeout, but only to decrease it. So you would have to increase the transaction timeout in the server configuration.

Hi there,
Thanks for your comment. Seems that there's not much I can do.

As for the unit part, you are right it's second, not ms. I mixed that up with something else.