-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to check connection error in mongojs #149
Comments
Getting following error: events.js:72 |
Hello @rohittailor You can do something like this. var mongojs = require('mongojs');
var db = mongojs('test', ['a']);
...
db.on('error', function() {
console.log('we had an error.');
}); And then it shouldn't throw. Let me know if you have any more problems. |
Hi Sorribas, I implemented that code and its working when mongodb up and we stop mongodb. But when mongodb is not running than i am getting same error and its not going in error callback. Please help. Thanks, |
It's true that it doesn't emit the error when the database is not running (we'll fix that), but I don't get the error thrown. What version of mongojs are you running? |
Hi Sorribas, Is this the same issue - ie on startup if the database doesn't exist I'm not getting an an error?
Above error not being logged if connection fails. Many thanks, |
Hi , I ran into this same problem with mongojs 1.3.0 on Windows 7 , I cant get any event when mongodb is not running or when I stop it.
|
I have the same issue as @bluedusk. If I don't have a mongodb server running, the app simply fails silently and exits. It should emit the Specs: |
I have the same issue as @Sparragus. mongojs 1.3.0 |
Same here. If the server was not running on 'connect', no error is thrown. |
same here. |
Is it going to be fixed? it's a showstopper for me. I saw some topic saying to use a connectionTimeout parameter like this: var db = mongojs( db_conn, ['bots'], {connectionTimeout: 3000} );
db.on('timeout', function (err) {
console.log('database timeout');
}); but it is still not working. |
Nothing worse than finding the issue you're struggling with in github only to discover it should have been fixed a year ago :) |
In version 2.0.0 you can register an error event listener with var db = mongojs( db_conn, ['bots'], {connectionTimeout: 3000} );
db.on('error', function (err) {
console.log('Connection errored', err);
}); |
That did not work for me, it throws the error and logged (app crashed) |
Hi,
How to check connection error in mongojs. When we run the app and mongodb is up than its working fine. When we stop mongodb, it throws an exception. Can we handle connection errors in mongojs ?
The text was updated successfully, but these errors were encountered: