我是第一次尝试pymongo,而且我一直在使用ServerSelectionTimeoutError。当使用mongo命令行登录时,我运行如下命令
$ mongo-3.0 --ssl test.net:27080/db_qa --sslAllowInvalidCertificates -u content -p
MongoDB shell version: 3.0.12
Enter password:我可以很好地连接,但是使用pymongo时,我会遇到错误
pymongo.errors.ServerSelectionTimeoutError: test.net:27080: [Errno 60] Operation timed out我的代码如下
from pymongo import MongoClient
client = MongoClient('mongodb://content:<password>@test.net:27080/db_qa')
client.server_info()发布于 2019-01-23 02:46:04
您的连接字符串缺少shell命令行提供的选项,即ssl和用于允许无效证书的选项。
您可以在传递给MongoClient的字符串中的数据库名称后面添加?ssl=true&ssl_cert_reqs=CERT_NONE,或者查看MongoClient页面上证书处理的其他选项(滚动到"SSL配置“部分)。
发布于 2021-07-24 00:55:48
所以对我起作用的是我刷新了我当前的IP,它在"setup connection security“标签下改变了
https://stackoverflow.com/questions/54064725
复制相似问题