Motor/pymongo连接超时与AWS DocumentDB

发布于 2025-01-29 13:50:06 字数 917 浏览 3 评论 0原文

我使用Python的电机库连接到AWS DocumentDB(MongoDB)实例。电动机在幕后使用Pymongo。

这一切都很好,但是突然我每当我尝试执行任何需要数据库操作的事情时都会获得连接超时:

pymongo.errors.ServerSelectionTimeoutError: aws-documentdb-endpoint:27017: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 628376f4a53a913de7752368, topology_type: Single, servers: [<ServerDescription ('aws-documentdb-endpoint', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('aws-documentdb-endpoint:27017: timed out')>]>

这就是我创建连接的方式,该连接效果很好,但是现在每次都会给出此超时错误时间:

from motor.motor_asyncio import AsyncIOMotorClient

client = AsyncIOMotorClient(
    host=os.environ["MONGO_URI"], 
    ssl=True, 
    ssl_cert_reqs=ssl.CERT_NONE, 
    ssl_ca_certs=os.path.join(os.environ["ROOT_DIR"], "cert", "aws", "rds-combined-ca-bundle.pem")
)

我不知道这是怎么回事,因为这已经运行了这么长时间,但是突然之间,我甚至都不认为我不认为我对代码的这一部分进行了任何更改。

I have used Python's Motor library to connect to an AWS DocumentDB (MongoDB) instance. Motor uses PyMongo behind the scenes.

This was all working fine, but suddenly I have been getting a connection timeout anytime I attempt to do anything that requires a database operation:

pymongo.errors.ServerSelectionTimeoutError: aws-documentdb-endpoint:27017: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 628376f4a53a913de7752368, topology_type: Single, servers: [<ServerDescription ('aws-documentdb-endpoint', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('aws-documentdb-endpoint:27017: timed out')>]>

This is how I am creating the connection, which has worked fine for weeks, but now gives this timeout error every time:

from motor.motor_asyncio import AsyncIOMotorClient

client = AsyncIOMotorClient(
    host=os.environ["MONGO_URI"], 
    ssl=True, 
    ssl_cert_reqs=ssl.CERT_NONE, 
    ssl_ca_certs=os.path.join(os.environ["ROOT_DIR"], "cert", "aws", "rds-combined-ca-bundle.pem")
)

I have no idea what is going wrong since this has been working fine for so long, but suddenly is not even thought I don't think I've made any changes to this part of the code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文