Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb没有重连机制 #133

Open
i5ting opened this issue Jun 25, 2018 · 1 comment
Open

mongodb没有重连机制 #133

i5ting opened this issue Jun 25, 2018 · 1 comment

Comments

@i5ting
Copy link
Member

i5ting commented Jun 25, 2018

当docker挂掉了,egg-cnode也挂掉了,当你重启了docker,egg-cnode依然是挂掉的

2018-06-25 13:37:44,233 ERROR 33312 [-/127.0.0.1/-/1ms GET /] nodejs.MongoError: Topology was destroyed
    at nextFunction (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongodb-core/lib/cursor.js:547:27)
    at Cursor.next [as _next] (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongodb-core/lib/cursor.js:701:3)
    at fetchDocs (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongodb/lib/cursor.js:857:10)
    at toArray (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongodb/lib/cursor.js:884:3)
    at Cursor.toArray (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongodb/lib/cursor.js:837:44)
    at /Users/i5ting/workspace/github/egg-cnode/node_modules/mquery/lib/collection/node.js:30:14
    at handleCallback (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongodb/lib/utils.js:120:56)
    at Collection.find (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongodb/lib/collection.js:384:44)
    at NativeCollection.(anonymous function) [as find] (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:130:28)
    at NodeCollection.find (/Users/i5ting/workspace/github/egg-cnode/node_modules/mquery/lib/collection/node.js:26:19)
    at model.Query.Query._find (/Users/i5ting/workspace/github/egg-cnode/node_modules/mongoose/lib/query.js:1353:27)
    at /Users/i5ting/workspace/github/egg-cnode/node_modules/kareem/index.js:250:8
    at /Users/i5ting/workspace/github/egg-cnode/node_modules/kareem/index.js:23:7
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

name: 'MongoError'
message: 'Topology was destroyed'
pid: 33312
hostname: MacBook-Pro-5.local

^C2018-06-25 13:38:18,852 INFO 33310 [master] receive signal SIGINT, closing

把下面配置加上,会好一些

  reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
  reconnectInterval: 500, // Reconnect every 500ms

参见 http://mongoosejs.com/docs/connections.html#options

@JacksonTian
Copy link
Member

PR welcome.

Debiancc added a commit to Debiancc/egg-cnode that referenced this issue Oct 1, 2018
Debiancc added a commit to Debiancc/egg-cnode that referenced this issue Oct 1, 2018
Debiancc added a commit to Debiancc/egg-cnode that referenced this issue Oct 1, 2018
Debiancc added a commit to Debiancc/egg-cnode that referenced this issue Oct 17, 2018
JacksonTian pushed a commit that referenced this issue Oct 17, 2018
* fix - Add connect MongoDB retry options(#133)

* fix - Update mongodb reconnect tries(#133)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants