The official Neo4j Python driver takes 20 seconds to establish a database connection, which is excessive. In the browser, it only takes 2 ms, and py2neo works fine. I'm using Python version 3.11 and have also tried other versions, 3.9 and 3.7. The Neo4j database has been used with three versions: latest, 5.12, and 5.13. The database was set up using Docker, and I've tried three different versions. All of them are empty databases. Do you have any solutions for this?
The time is in the lower left corner of the picture, the same query, py2neo runs in less than 1s
I ran this code on my other computer, and the result was the same as yours. Both computers are using WSL, one with Debian and the other with Ubuntu (which is working fine). I'm curious why the problematic session doesn't consume time.
But considering docker networking + wsl networking is at play, I would widen the investigation and also look at what may be causing issues there. It does not hurt to double check layer by layer how fast you can reach the container running the db.
It is indeed a network issue; it points localhost to [::1], but Docker does not have IPv6 enabled. I tried to fix this problem, but after removing [::1] from the hosts file, localhost still points to [::1]. I resolved it by setting Bolt to 127.0.0.1.
My windows skills are not what they used to be. I would assume it has gotten more complicated than just the hosts file these days. I think there are many ways of running docker in wsl as well. Hopefully you can find bits and pieces in windows forums or by searching the web.