副本集有套接字选项: http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html
此外,服务器还有套接字选项 http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html
现在,我连接到我的副本
var MongoClient = require('mongodb').MongoClient;
var ReplSet = require('mongodb').ReplSet;
var Server = require('mongodb').Server;
var servers = [
new Server('srv1', 27017, {socketOptions: {socketTimeoutMS: 100000}}, new Server('srv2', 27017, {socketOptions: {socketTimeoutMS: 100000} }, new Server('srv3', 27017, { socketOptions: {socketTimeoutMS: 100000}},];
var replSet = new ReplSet(servers, {
socketOptions: { socketTimeoutMS: 666666 }
});
var dbConnStr = "mongodb://user:pass@srv1,srv2,srv3/mydb?replicaSet=lw&readPreference=secondary";
MongClient.connect(dConnStr, {replSet: replSet}, {function(err, dbConn) {
//
});
现在的问题是:当副本集的设置与服务器阵列中每个服务器的设置不同时,实际应用了什么套接字超时。
另外,奖励问题:如果副本集对象中有数组,为什么我需要在连接字符串上设置副本服务器?