【发布时间】:2019-11-21 17:21:00
【问题描述】:
我正在运行 MongoDB 的启动代码,试图连接到我刚刚在 MongoDB Atlas 中设置的集群。我收到服务器选择超时错误。
我无法在 MongoDB 故障排除文档中找到有关此问题的任何内容。
client = pymongo.MongoClient(
"mongodb+srv://USR:PWD@cluster0-eoik8.mongodb.net/test?retryWrites=true&w=majority")
db = client.admin
pprint(db.command("serverStatus"))
我已正确编码 URL(使用在线 URL 编码服务)。
错误是
pymongo.errors.ServerSelectionTimeoutError: connection closed,connection closed,connection closed
【问题讨论】:
-
我也有这些错误,但它是间歇性的,我使用的是 gunicorn + gevent。随着我们获得微量流量,问题变得更糟。
标签: python mongodb mongodb-atlas