Callbacks Stop Happening
See original GitHub issueI’ve been using mongoose
for a few years, but lately I’m having a lot of trouble where the connection seems to disappear.
Connection Settings
// Connecting to MongoDB 3.2.1
var connString = "mongodb://xxxxx:xxxxx@xxxxx:xxxx,xxxx:xxxx/xxx?ssl=true";
var connOptions = {
"mongos": { "ssl": true, "sslValidate": false }
};
mongoose.connect(connString, connOptions, function(err, db) {
if(err) { console.log("Error connecting to db: "+err); }
});
The Problem
Mongoose just stops calling back. It doesn’t emit any errors, memory/cpu is fine on my server & db, and I can connect from any other server. Restarting always fixes it:
db.Something.count({}, callback);
Versions
On mongoose 4.4.11
, mongoose.connection.readyState === UNAUTHORIZED
when callbacks stop.
So I upgraded to mongoose 4.6.0
but within 4 hours the callbacks stopped again, now with mongoose.connection.readyState === CONNECTED
.
Any Ideas
Any ideas how I can get this to stop happening?
I’m happy to gather any more debugging info, just let me know what info to get.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:53 (1 by maintainers)
Top Results From Across the Web
How to stop training a neural-network using callback?
In this brief tutorial, we learn how to stop training a Deep Neural Network in Tensorflow and Keras, using the callback approach, ...
Read more >What is the difference between TensorFlow's callbacks and ...
A callback function (e.g. early stopping) is a function that is passed as an argument to another function (e.g. fitting an ML model),...
Read more >Use Early Stopping to Halt the Training of Neural Networks At ...
The EarlyStopping callback will stop training once triggered, but the model at the end of training may not be the model with best...
Read more >tf.keras.callbacks.EarlyStopping | TensorFlow v2.11.0
Stop training when a monitored metric has stopped improving. ... This callback will stop the training when there is no improvement in
Read more >EarlyStopping callback behaving mysteriously in Keras
I think your interpretation of the EarlyStopping callback is a little off; it stops when the loss doesn't improve from the best loss...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unfortunately gonna have to push this one back again because mongodb driver is held up from releasing. Sorry about that and thanks for your patience 👍 🌴
thanks for testing! Indeed Mongoose always stays connected, but callbacks stop happening (you can see the request coming into Express, but they’ll timeout)
I was testing with:
I’ve updated to:
I can still reproduce the issue locally with the first script I posted. It only occurs when a Mongo connection times out, so you might want to change the query that simulates this:
(I’m not sure if this will trigger a timeout on every machine so a change to this query might be necessary to reproduce)