Fay*_*yes 1 bots mongodb node.js slack mongodb-atlas
使用 Botkit 创建 slack bot,但无法连接到 Mongo Atlas 进行存储。Node.js 后端。使用 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`})
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,我收到此错误:
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>'
}]
Run Code Online (Sandbox Code Playgroud)
依赖项:
"dependencies": {
"botkit": "0.6.21",
"botkit-storage-mongo": "1.0.7",
"mongodb": "^3.5.0"
}
Run Code Online (Sandbox Code Playgroud)
在 Mongo Atlas 中,我的 IP 地址被列入白名单。还测试允许所有 IP:0.0.0.0/0。
关于为什么我无法连接的任何想法?
这个问题与botkit无关。
需要更新 mongo atlas 仪表板中的连接驱动程序版本。
是 Node.js 3.0 或更高版本的驱动程序。当我将其更改为 Node.js 2.2.12 或更高版本时,该连接字符串有效。
| 归档时间: |
|
| 查看次数: |
2164 次 |
| 最近记录: |