Mongo Atlas连接问题

mongo atlas connection troubles

提问人:chilly_maximus 提问时间:4/6/2021 最后编辑:Christian Fritzchilly_maximus 更新时间:4/6/2021 访问量:209

问:

我有一个应用程序,在meteor.js中创建,但我认为它不应该重要。我在mongo atlas上也有mongo集群。到目前为止,在开发过程中,我通过连接字符串连接到数据库,没有问题地从我的本地机器。但是,当我在 DigitalOcean 上创建 linux 机器并尝试使用相同的连接字符串连接我的应用程序时mongodb+srv://<user>:<password>@xyz.mongodb.net/<dbName>?retryWrites=true&w=majority

我收到以下错误。

MongoNetworkError: failed to connect to server [xyz.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to xyz.mongodb.net:27017 closed
    at TLSSocket.<anonymous> (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:440:9)
    at Object.onceWrapper (events.js:421:26)
    at TLSSocket.emit (events.js:314:20)
    at TLSSocket.EventEmitter.emit (domain.js:483:12)
    at net.js:675:12
    at TCP.done (_tls_wrap.js:568:7)]
    at Pool.<anonymous> (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/topologies/server.js:438:11)
    at Pool.emit (events.js:314:20)
    at Pool.EventEmitter.emit (domain.js:483:12)
    at /home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:562:14
    at /home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:1009:9
    at callback (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:75:5)
    at /home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:101:9
    at _callback (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:329:7)
    at Connection.errorHandler (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:344:7)
    at Object.onceWrapper (events.js:421:26)
    at Connection.emit (events.js:314:20)
    at Connection.EventEmitter.emit (domain.js:483:12)
    at TLSSocket.<anonymous> (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:438:12)
    at Object.onceWrapper (events.js:421:26)
    at TLSSocket.emit (events.js:314:20)
    at TLSSocket.EventEmitter.emit (domain.js:483:12)

你知道我的服务器配置可能有什么问题吗?我想这是服务器配置,因为在其他机器上相同的连接字符串有效。

MongoDB Meteor 数字海洋

评论

1赞 dododo 4/6/2021
检查配置,例如,如果使用 ,可以检查当前 IP 是否在列表中network accessIP Whitelist
0赞 Christian Fritz 4/6/2021
从您的数字海洋实例中检查的内容:您可以 ping 吗?当你会发生什么?atlas 实例上的日志是怎么说的,是否有任何迹象表明它拒绝了连接尝试?xyz.mongodb.nettelnet xyz.mongodb.net 27017
0赞 chilly_maximus 4/6/2021
@ChristianFritz ping:xyz.abaz9.mongodb.net:27017:名称或服务未知 telnet:无法解析 xyz.abaz9.mongodb.net:27017/telnet:名称或服务未知。我感到羞耻,但我没有看到 isee 何时登录 atlas 实例。
0赞 Christian Fritz 4/6/2021
不应将端口号与 ping 一起使用;请再看看我要求ping的内容。
0赞 chilly_maximus 4/6/2021
@ChristianFritz对不起。ping没有问题。telnet 仅打印尝试 18.193.58.103。

答: 暂无答案