ServiceUnavailable Failed to read from defunct connection with Flask uwsgi neo4j
duclinhfetel opened this issue · 0 comments
duclinhfetel commented
Issue
I use Flask + uwsgi + neo4j.
With a large number of requests at the same time, uwsgi forks out many workers to handle the request, then I get the error below:
neo4j.exceptions.ServiceUnavailable: Failed to read from defunct connection IPv4Address(('neo4j', 7687)) (ResolvedIPv4Address(('172.23.0.5', 7687)))
Can anyone help me fix this issue?
Thanks.
my neo4j driver config :
config = {
"uri": "bolt://ip:7687",
"auth": ("neo4j", "password"),
"encrypted": False,
"max_connection_lifetime": 30 * 60,
"max_connection_pool_size": 50,
"connection_acquisition_timeout": 2*60,
"connection_timeout":15
}
# init neo4j driver
driver = GraphDatabase.driver(**config)
# query with session
with driver.session() as session:
results = session.run(query).to_eager_result()
uwsgi config
...
enable-threads = true
processes = 32 ; Maximum number of workers allowed
My Environment
- Python Version: python==3.8.18
- Driver Version: neo4j==5.11.0
- Neo4j Database: docker neo4j:5.11.0
- Operating System: Ubuntu 20.04 LTS