-
Type:
Task
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 2.1.16
-
Component/s: None
Hi. I'm writing a simple script that is meant to connect to mongo and insert some records.
Here's what I came up with:
var db; // shared connection
var url = 'mongodb://localhost:27017/project'
MongoClient.connect(url,
, function(err, mongoClient) {
if(err)
db = mongoClient;
});
// TODO mongoClient.close();
My script starts up mongo and tries to connect immediately.
It turns out that there's a delay between mongo startup and the point of time when it opens a socket connection.
So my script fails with "Error: connect ECONNREFUSED 127.0.0.1:27017"
Is it an expected behavior?
I don't believe that it can't recover from such an error.
Maybe I don't understand something.