"SessionExpired: Failed to read from defunct connection " when using Python driver > v5.27.0
I’m currently using Neo4j database 5.26.4 with the official Python driver 5.27.0 and Python 3.10.12.
When I upgrade the driver to any version beyond 5.27.0, I start getting intermittent SessionExpired errors during the Bolt handshake:
neo4j.exceptions.SessionExpired: Failed to read from defunct connection
The same issue occurs for both:
- GraphDatabase (sync) , AsyncGraphDatabase (async)
- Neomodel db (sync) , AsyncDatabase (async)
With version 5.27.0, the connection is stable. With newer driver versions, the connection sometimes doesn’t establish successfully with the error above.
Environment details:
- Python: 3.10.12,
- OS: Ubuntu 22.04,
- Database: Neo4j 5.26.4 ,
- Bolt protocol: (5, 7)
Has anyone else faced similar intermittent connection failures with driver versions after 5.27.0? Any suggestions that help stabilize the connection would be appreciated.
Thanks.
Hi and thanks for reaching out. Could you share driver debug logs that allow me to compare a successful run on 5.26.4 with an unsuccessful one on 5.27.0.