无法连接到Mongo Atlas getaddrinfo ENOTFOUND [集群名称]

问题描述 投票:0回答:1

使用Botkit创建松弛机器人,但无法连接到Mongo Atlas进行存储。 Nodejs后端。使用Botkit-storage-mongo

代码:

var Botkit = require('botkit');
var BotkitStorage = require('botkit-storage-mongo');
storage = BotkitStorage({ mongoUri: `mongodb+srv://<username>:<password>@<clustername>/test?retryWrites=true&w=majority`})

运行代码时出现此错误:

UnhandledPromiseRejectionWarning: Error: MongoError: failed to connect to server [<cluster_name>] on first connect [Error: getaddrinfo ENOTFOUND <cluster_name>
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26) {
  name: 'MongoError',
  message: 'getaddrinfo ENOTFOUND <cluster_name>'
}]

依赖关系:

  "dependencies": {
    "botkit": "0.6.21",
    "botkit-storage-mongo": "1.0.7",
    "mongodb": "^3.5.0"
  }

在Mongo Atlas中,我的IP地址已列入白名单。还测试允许所有IP:0.0.0.0/0。

关于为什么我无法连接的任何想法?

node.js mongodb bots slack mongodb-atlas
1个回答
0
投票

此问题与botkit无关。

需要更新mongo atlas仪表板中的连接驱动程序版本。

是Node.js 3.0或更高版本的驱动程序。当我将其更改为Node.js 2.2.12或更高版本时,该连接字符串起作用。

© www.soinside.com 2019 - 2024. All rights reserved.