node.js - 无法在 Gatsby 项目中连接 MongoDb Atlas
问题描述
我使用 Gatsby 和 MongoDb Atlas。我可以从 Compass 或任何其他客户端连接我的 MongoDb。但是,我无法从 Gatsby 连接。我总是出错。
我尝试了很多东西来解决这个问题。我从 MongoDb Atlas 的网络访问中删除了所有 IP 地址,并尝试不使用 IP 地址,它不起作用。然后,我只尝试 0.0.0.0 Ip,没有任何改变。然后我清除所有 npm 包并尝试,但一切都是一样的。
MongoServerSelectionError: connection <monitor> to 54.93.42.35:27017 closed
at Timeout._onTimeout (E:\Kisisel\gatsbyTest\node_modules\mongodb\lib\core\sdam\topology.js:438:30)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map {
'cluster0-shard-00-00.tl25n.mongodb.net:27017' => [ServerDescription],
'cluster0-shard-00-02.tl25n.mongodb.net:27017' => [ServerDescription],
'cluster0-shard-00-01.tl25n.mongodb.net:27017' => [ServerDescription]
},
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
}
}
我的连接字符串:
mongodb+srv://<username>:<password>@cluster0.tl25n.mongodb.net/<dbName>?retryWrites=true&ssl=true
解决方案
推荐阅读
- botframework - 在 Teams 中为 botframework 虚拟助手启用单点登录
- python - 抑制 DeprecationWarning 并不总是有效
- r - ts_ts 用于 R 中的时间序列
- asp.net - 元素内部文本的 XML 文件转换?
- javascript - JavaScript 中 .reduce() 和 .every() 的区别
- django - 如何在 Django 中从一组模型字段到另一组模型字段对 unique_together 约束进行更改
- azure - 如何使用我的 AAD 凭据登录到我的 Azure VM?
- outlook - 通过 OLE Outlook 从返回的电子邮件中获取诊断信息
- reporting-services - ssrs 2014 的拆分和切换功能
- vue.js - 在输入 VUE-JS 中确认后更改值