2017-02-18 4 views
0

以下はherokuログの出力です。私は、接続がHeroku nodejs/mongooseとmLabアプリがタイムアウトでクラッシュする

socketTimeoutMS: 0, 
    connectionTimeout: 0 

パラメータが、それでも私はそのためのMLABに連絡を

[web.1]: events.js:160 
[web.1]:  throw er; // Unhandled 'error' event 
[web.1]:  ^
[web.1]: 
[web.1]: Error: connection timeout 
/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:169:17) 
........ 
[web.1]: npm ERR! Linux 3.13.0-105-generic 
/.heroku/node/bin/npm" "start" 
[web.1]: npm ERR! node v6.9.5 
[web.1]: npm ERR! npm v3.10.10 
[web.1]: npm ERR! code ELIFECYCLE 
+0

あなたはmongo labsの正しいアドレスと認証パスワードを与えていますか? –

+0

にも、MongoDBのバージョン何しているマングースのバージョン –

+0

@RaviShankarはい。以前もそれは以前から仕事をしていました。 – rahmanisback

答えて

1

をoccures設定しようとしました。サポートスタッフの対応は次のとおりです。

ヘロクから接続するときに30秒の接続タイムアウトを提案することがよくあります。以下はhttps://gist.github.com/mongolab-org/9959376

はそのgithubのが主旨で接続構成です:あなたはここに私たちの提案マングースの設定を見ることができます

// mongoose 4.3.x 
var mongoose = require('mongoose'); 

/* 
* Mongoose by default sets the auto_reconnect option to true. 
* We recommend setting socket options at both the server and replica set level. 
* We recommend a 30 second connection timeout because it allows for 
* plenty of time in most operating environments. 
*/ 
var options = { server: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } }, 
       replset: { socketOptions: { keepAlive: 300000, connectTimeoutMS : 30000 } } };  

var mongodbUri = 'mongodb://user:[email protected]:port/db'; 

mongoose.connect(mongodbUri, options); 
var conn = mongoose.connection;    

conn.on('error', console.error.bind(console, 'connection error:')); 

conn.once('open', function() { 
    // Wait for the database connection to establish, then start the app.       
}); 
あなたが使用しているMLAB
関連する問題