当我尝试连接到 MongoDB 云时,在我没有收到该错误之前收到此错误

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

npm 启动

> [email protected] start
> nodemon index.js       

[nodemon] 3.0.2
[nodemon] to restart at any time, enter `rs`  
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node index.js`
Example app listening on port 5000
MongoServerSelectionError: unable to verify the first certificate
    at EventTarget.<anonymous> (C:\Users\wroja\Downloads\Nueva carpeta\Mern book Projects\mern-server\node_modules\mongodb\lib\sdam\topology.js:276:34)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:814:20)
    at EventTarget.dispatchEvent (node:internal/event_target:749:26)
    at abortSignal (node:internal/abort_controller:371:10)
    at TimeoutController.abort (node:internal/abort_controller:393:5)
    at Timeout.<anonymous> (C:\Users\wroja\Downloads\Nueva carpeta\Mern book Projects\mern-server\node_modules\mongodb\lib\utils.js:1011:92)     
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-yy5xiu1-shard-00-00.nopzuti.mongodb.net:27017' => [ServerDescription],
      'ac-yy5xiu1-shard-00-01.nopzuti.mongodb.net:27017' => [ServerDescription],
      'ac-yy5xiu1-shard-00-02.nopzuti.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-qh7ckq-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {},
  [cause]: MongoNetworkError: unable to verify the first certificate
      at connectionFailureError (C:\Users\wroja\Downloads\Nueva carpeta\Mern book Projects\mern-server\node_modules\mongodb\lib\cmap\connect.js:379:20)
      at TLSSocket.<anonymous> (C:\Users\wroja\Downloads\Nueva carpeta\Mern book Projects\mern-server\node_modules\mongodb\lib\cmap\connect.js:285:22)
      at Object.onceWrapper (node:events:629:26)
      at TLSSocket.emit (node:events:514:28)
      at emitErrorNT (node:internal/streams/destroy:151:8)
      at emitErrorCloseNT (node:internal/streams/destroy:116:3)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    [Symbol(errorLabels)]: Set(1) { 'ResetPool' },
    [cause]: Error: unable to verify the first certificate
        at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
        at TLSSocket.emit (node:events:514:28)
        at TLSSocket._finishInit (node:_tls_wrap:1085:8)
        at ssl.onhandshakedone (node:_tls_wrap:871:12) {
      code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
    }
  }
}

重新启动计算机并重新创建数据库

javascript reactjs node.js mongodb mongoose
1个回答
0
投票

SSL证书有问题,重新生成并尝试。 之后您可以尝试其他选项 -

1.) 检查 MongoDB 连接设置

2.) 更新 mongoDB 驱动程序

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