【问题标题】:MongoError: command aggregate requires authenticationMongoError:命令聚合需要身份验证
【发布时间】:2019-03-25 18:15:37
【问题描述】:

从 firebase 函数连接到 mongodb atlas 时,我随机出现以下错误。知道是什么原因造成的(似乎无需任何干预即可自动修复)?

{ 
MongoError: command aggregate requires authentication
at queryCallback (/user_code/node_modules/mongoose/node_modules/mongodb-core/lib/cursor.js:248:25)
at /user_code/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:532:18
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1540073032 },
ok: 0,
errmsg: 'command aggregate requires authentication',
code: 13,
codeName: 'Unauthorized',
'$clusterTime': 
{ clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1540073032 },
signature: { hash: [Object], keyId: [Object] } },
name: 'MongoError' 
}

【问题讨论】:

  • 我假设您已经检查了错误所暗示的身份验证?
  • 这是随机发生的。如果我重新部署 firebase 功能,它大部分时间都会得到修复。发生的情况是应用程序在一段时间内正常工作,然后突然这些错误开始出现,这有效地停止了依赖数据库的每个操作。

标签: mongodb mongoose google-cloud-functions mongodb-atlas


【解决方案1】:

我面临着类似的事情。原来当我使用隧道在本地运行代码时,它不会在服务器上运行。所以这是一个愚蠢的错误。检查是否没有其他 mongodb 实例在使用中。

【讨论】:

    猜你喜欢
    • 2020-08-15
    • 1970-01-01
    • 2021-04-10
    • 2022-01-10
    • 2019-12-17
    • 2019-07-20
    • 2021-11-22
    • 2019-09-02
    • 2015-11-13
    相关资源
    最近更新 更多