我正在使用代码集连接我的 mongo 副本集
var mongojs = require('mongojs'); var replicationSet = "primary:27017,secondary:27017"; var replicaSetName = "rs"; var readPreference = "最近的"; var readPreferenceTags = "dc:test"; var generateMongoUri = 函数(用户名、pswd、db、authdb){ var url = format("mongodb://%s:%s@%s/%s?authSource=%s&replicaSet=%s&readPreference=%s&readPreferenceTags=%s&connectTimeoutMS=%s&socketTimeoutMS=%s", username, pswd, replicationSet, db , authdb, replicaSetName, readPreference, readPreferenceTags, 5000, 5000); 返回网址; }; var userurl = generateMongoUri(用户名,用户名, pswd, db, authdb); var db = mongojs(userurl);
不经常,但有时我会收到此错误并且我的节点崩溃,我什至不明白为什么会弹出此错误
E:\NodeServer\node_modules\mongodb\lib\db.js:309
handleCallback(callback, null, result.result);
^
TypeError: Cannot read property 'result' of undefined
at E:\NodeServer\V122\node_modules\mongodb\lib\db.js:309:42
at ReplSet.command (E:\NodeServer\V122\node_modules\mongodb-core\lib\topologies\replset.js:1094:
42)
at ReplSet.command (E:\NodeServer\V122\node_modules\mongodb\lib\replset.js:388:18)
at Store.execute (E:\NodeServer\V122\node_modules\mongodb\lib\topology_base.js:108:30)
at done (E:\NodeServer\V122\node_modules\mongodb-core\lib\topologies\replset.js:267:40)
at null.<anonymous> (E:\NodeServer\V122\node_modules\mongodb-core\lib\topologies\replset.js:342:
9)
at g (events.js:260:16)
at emitOne (events.js:77:13)
at emit (events.js:169:7)
at E:\NodeServer\V122\node_modules\mongodb-core\lib\topologies\server.js:283:14
at E:\NodeServer\V122\node_modules\mongodb-core\lib\connection\pool.js:436:18
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
谁能告诉我在什么情况下会弹出这个错误???