为什么在节点上连接mongodb总是出现错误“列表中没有有效的种子服务器”

我写了一个简单的节点应用程序,并处理一个简单的写入和从MongoDB读取。

该应用程序运行良好,但是,一段时间后,服务器被卡住,并注销:

{ [MongoError: no valid seed servers in list] name: 'MongoError', message: 'no valid seed servers in list' } 

连接代码是这样的:

 var mongodb = require('mongodb'); var MongoClient = mongodb.MongoClient; var url = 'mongodb://mongodb-server-2.xxx.com:27000,mongodb-server-3.xxx.com:27000,mongodb-arbiter-0.fotor.mobi:27000/mydb'; var options = { db: { readPreference: mongodb.ReadPreference.PRIMARY, slaveOk: true }, replSet: { replicaSet: 'ei-repl0' }, server: { w: 1, autoReconnect: true }}; MongoClient.connect(url,options, function(err, db) { //do some mongodb process... }) 

和rs.status()是这样的:

 { "set" : "ei-repl0", "date" : ISODate("2016-01-30T03:07:22.515Z"), "myState" : 1, "members" : [ { "_id" : 0, "name" : "mongodb-server-2.xxx.com:27000", "health" : 1.0000000000000000, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 1.89144e+006, "optime" : Timestamp(1454123242, 1), "optimeDate" : ISODate("2016-01-30T03:07:22.000Z"), "lastHeartbeat" : ISODate("2016-01-30T03:07:22.161Z"), "lastHeartbeatRecv" : ISODate("2016-01-30T03:07:22.050Z"), "pingMs" : 1, "syncingTo" : "mongodb-server-3.xxx.com:27000", "configVersion" : 5 }, { "_id" : 1, "name" : "mongodb-server-3.xxx.com:27000", "health" : 1.0000000000000000, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 1.89333e+006, "optime" : Timestamp(1454123242, 2), "optimeDate" : ISODate("2016-01-30T03:07:22.000Z"), "electionTime" : Timestamp(1452231590, 1), "electionDate" : ISODate("2016-01-08T05:39:50.000Z"), "configVersion" : 5, "self" : true }, { "_id" : 2, "name" : "mongodb-arbiter-0.xxx.com:27000", "health" : 1.0000000000000000, "state" : 7, "stateStr" : "ARBITER", "uptime" : 1.89176e+006, "lastHeartbeat" : ISODate("2016-01-30T03:07:20.974Z"), "lastHeartbeatRecv" : ISODate("2016-01-30T03:07:22.434Z"), "pingMs" : 1, "configVersion" : 5 } ], "ok" : 1.0000000000000000 } 

可能是什么问题呢?

       

网上收集的解决方案 "为什么在节点上连接mongodb总是出现错误“列表中没有有效的种子服务器”"