egg icon indicating copy to clipboard operation
egg copied to clipboard

我使用的egg-mongoose出现了disconnect情况

Open johnsmithsren opened this issue 2 years ago • 1 comments

不是bug!只是对此有点疑惑,希望有人能够帮助一下,不清楚是哪里配置有问题。

  1. 一开始链接 egg-mongoose 是正常的,但是经过了一两天之后,就会偶尔出现 disconnect 报错

[egg-mongoose] mongodb://xxxxxx disconnected 53863 has failed with connection to xxxxx timed out

config.mongoose = { client: {

  url: 'mongodb://xxxxxxxx?authSource=admin&compressors=zlib',
  options: {
    useUnifiedTopology: true,
    useNewUrlParser: true,
  },
},

};

我的配置大概是这样,除了disconnect报错,也没有其他信息了,我不清楚是配置方面出了什么问题导致的,之前的版本一直没什么异常

Reproduction Repo

null

Node Version

16.19.1

Eggjs Version

3.12.0

Plugin Name and its version

"egg-mongoose": "^3.3.1"

Platform and its version

ubuntu

johnsmithsren avatar Feb 24 '23 04:02 johnsmithsren

应该是当时MongoDB驱动库跟MongoDB数据库节点的心跳检测不通,MongoDB驱动库触发了disconnected,建议检查下当时是否网络有问题。useUnifiedTopology参数为true,所以mongoose会开启心跳检测

sinkhaha avatar Mar 08 '23 16:03 sinkhaha