简体   繁体   English

ServerSelectionTimeoutError Pymongo

[英]ServerSelectionTimeoutError Pymongo

I'm trying out pymongo for the first time and I keep getting a ServerSelectionTimeoutError.我是第一次尝试 pymongo,但一直收到 ServerSelectionTimeoutError。 When using mongo commandline to login I run a command as follows使用 mongo 命令行登录时,我运行如下命令

$ mongo-3.0 --ssl test.net:27080/db_qa --sslAllowInvalidCertificates -u content -p
MongoDB shell version: 3.0.12
Enter password:

and I'm able to connect fine but with pymongo I get the error我可以正常连接,但是使用 pymongo 时出现错误

pymongo.errors.ServerSelectionTimeoutError: test.net:27080: [Errno 60] Operation timed out

My code is as follows我的代码如下

from pymongo import MongoClient

client = MongoClient('mongodb://content:<password>@test.net:27080/db_qa')
client.server_info()

Your connection string is missing the options that your shell command line provides, namely ssl and option to allow invalid certificate.您的连接字符串缺少 shell 命令行提供的选项,即ssl和允许无效证书的选项。

You could add ?ssl=true&ssl_cert_reqs=CERT_NONE after the database name in the string you are passing to MongoClient or see other options for certificate handling on MongoClient page (scroll to "SSL configuration" section)您可以在传递给MongoClient的字符串中的数据库名称之后添加?ssl=true&ssl_cert_reqs=CERT_NONE或在MongoClient页面上查看证书处理的其他选项(滚动到“SSL 配置”部分)

因此,对我有用的是我刷新了在“设置连接安全性”选项卡下更改的当前 IP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 PyMongo 3 给出 ServerSelectionTimeoutError? - Why is PyMongo 3 giving ServerSelectionTimeoutError? pymongo.errors.ServerSelectionTimeoutError - pymongo.errors.ServerSelectionTimeoutError 烧瓶 - pymongo.errors.ServerSelectionTimeoutError - Flask - pymongo.errors.ServerSelectionTimeoutError 升级到PyMongo 3.0导致ServerSelectionTimeoutError - Upgrade to PyMongo 3.0 Resulting in ServerSelectionTimeoutError 使用 pymongo 连接到 aws 时出现 ServerSelectionTimeoutError - ServerSelectionTimeoutError when connecting to aws with pymongo pymongo.errors.ServerSelectionTimeoutError: RepliceSetNoPrimary - MongoDB Atlas - pymongo.errors.ServerSelectionTimeoutError: RepliceSetNoPrimary - MongoDB Atlas Pymongo读取首选项-ServerSelectionTimeoutError:无主要可用于写入 - Pymongo Read Preferences - ServerSelectionTimeoutError: No primary available for writes 使用 pymongo 连接到 Atlas MongoDb - ServerSelectionTimeoutError - Connecting to Atlas MongoDb using pymongo - ServerSelectionTimeoutError Pymongo pymongo.errors.ServerSelectionTimeoutError 使用示例代码时 - Pymongo pymongo.errors.ServerSelectionTimeoutError when using example code 连接到 mongo 图集给出 pymongo.errors.ServerSelectionTimeoutError: localhost:27017 - Connecting to mongo atlas gives pymongo.errors.ServerSelectionTimeoutError: localhost:27017
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM