Agenda: Auto reconnect not working

Created on 11 Sep 2018  路  4Comments  路  Source: agenda/agenda

 MongoDB connection is not recoverable, application restart required 

at Agenda.module.exports [as _findAndLockNextJob]

Most helpful comment

Yes, It does.

Look at the documentation:

Recovering lost Mongo connections ("auto_reconnect")
Agenda is configured by default to automatically reconnect indefinitely, emitting an error event when no connection is available on each process tick, allowing you to restore the Mongo instance without having to restart the application.

However, if you are using an existing Mongo client you'll need to configure the reconnectTries and reconnectInterval connection settings manually, otherwise you'll find that Agenda will throw an error with the message "MongoDB connection is not recoverable, application restart required" if the connection cannot be recovered within 30 seconds.

What the documentation _doesnt say_, is that if you don't handle the error by:
agenda.on(error, (err, job) => { ... });

The reconnect doesn't work.

I think they should absolutely include that part in the documentation.
Let me know if that works for you.

All 4 comments

try to catch error:
agenda.on(error, (err, job) => {
...
});

By catching it, the recconect will work

@nogalavi thanks, isn't auto reconnect part of the features that agenda offers ?

Yes, It does.

Look at the documentation:

Recovering lost Mongo connections ("auto_reconnect")
Agenda is configured by default to automatically reconnect indefinitely, emitting an error event when no connection is available on each process tick, allowing you to restore the Mongo instance without having to restart the application.

However, if you are using an existing Mongo client you'll need to configure the reconnectTries and reconnectInterval connection settings manually, otherwise you'll find that Agenda will throw an error with the message "MongoDB connection is not recoverable, application restart required" if the connection cannot be recovered within 30 seconds.

What the documentation _doesnt say_, is that if you don't handle the error by:
agenda.on(error, (err, job) => { ... });

The reconnect doesn't work.

I think they should absolutely include that part in the documentation.
Let me know if that works for you.

agenda.on(error, (err, job) => { ... }); doesn't catch this error: MongoDB connection is not recoverable, application restart required and app crashes. Any suggestions?

Was this page helpful?
0 / 5 - 0 ratings