mongodb 有一個坑 報錯 no mongos proxies found in seed list

來源:互聯網
上載者:User

標籤:prototype   style   option   img   報錯   bsp   handle   串連   怎麼辦   

mongoose 的報當我從 [email protected] 升級到 [email protected]的時候,出現了一個問題:

Unhandled rejection MongoError: no mongos proxies found in seed list

怎麼辦,我google 一下的時候發現:

  https://github.com/christkv/mongodb-core/issues/118

原來是mongo的一個bug

 

 

哎呦!看下源碼,這是[email protected]

Mongoose.prototype.createConnection = function(uri, options) {
var conn = new Connection(this);
this.connections.push(conn);

var rsOption = options && (options.replset || options.replSet);
if (arguments.length) {
if (rgxReplSet.test(arguments[0]) || checkReplicaSetInUri(arguments[0])) {
conn.openSet.apply(conn, arguments);
} else if (rsOption &&
(rsOption.replicaSet || rsOption.rs_name)) {
conn.openSet.apply(conn, arguments);
} else {
conn.open.apply(conn, arguments);
}
}

return conn;
};
再看下低版本的[email protected]
Mongoose.prototype.createConnection = function(uri, options) {
var conn = new Connection(this);
this.connections.push(conn);

if (arguments.length) {
if (rgxReplSet.test(arguments[0]) || checkReplicaSetInUri(arguments[0])) {
conn.openSet.apply(conn, arguments);
} else if (options && options.replset &&
(options.replset.replicaSet || options.replset.rs_name)) {
conn.openSet.apply(conn, arguments);
} else {
conn.open.apply(conn, arguments);
}
}

return conn;
};
也就是說,在低版本中,你的mongodb 做了複製集的配置和不做複製集的配置都能串連到mongodb,在高本中如果你做了複製集,options 中的參數需要加一個
replset或者replSet S為true,而沒有做複製集的要為false。

 

mongodb 有一個坑 報錯 no mongos proxies found in seed list

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.