2017-12-01 6 views
0

イムを使用してクラスタをモンゴに接続するために、私はこの方法最良の方法は、クラスタをMongoのために私のノードアプリを接続しようとマングース

var options = { 
useMongoClient: true, 
autoIndex: false, 
reconnectTries: Number.MAX_VALUE, 
reconnectInterval: 500, 
poolSize: 10, 
bufferMaxEntries: 0 
}; 

var cluster = "my cluster url XXX"; 
mongoose.connect(cluster, options); 

を使用しているが、それは

(node:8701) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): MongoError: topology was destroyed (node:8701) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that a re not handled will terminate the Node.js process with a non-zero exit code.

は、私が知っているこのエラーを投げますこれはクラスタに接続する正しい方法ではありません。 誰にでも最高の方法とその理由を教えてください。(例で) ありがとう!!

+0

の可能性のある重複:のhttps://stackoverflow.com/questions/30909492/mongoerror-topology-was-destroyed – kentor

+0

可能性のある重複した[mongoError:トポロジが破壊された(HTTPS:/ /stackoverflow.com/questions/30909492/mongoerror-topology-was-destroyed) – kentor

答えて

0

試してみてください。

mongoose.connect('mongodb://'+ip+':'+port+'/'+database, function(err) {}); 
mongoose.connection.on('connected', function() {}); 
mongoose.connection.on('disconnected', function() {}); 
関連する問題