Open dgatto opened 3 years ago
This should be split across server and db retry, separately.
Mongo already seems to have baked in retry functionality.
https://stackoverflow.com/questions/39785036/reliably-reconnect-to-mongodb
var MongoClient = require('mongodb').MongoClient,
f = require('util').format;
MongoClient.connect('mongodb://localhost:27017/test',
{
// retry to connect for 60 times
reconnectTries: 60,
// wait 1 second before retrying
reconnectInterval: 1000
},
function(err, db) {
var col = db.collection('t');
setInterval(function() {
col.insert({
a: 1
}, function(err, r) {
console.log("insert")
console.log(err)
col.findOne({}, function(err, doc) {
console.log("findOne")
console.log(err)
});
})
}, 1000)
});
Should there be a "minimum data pre-req" idea? Like, you have a "low-connection-mode" and just have the bare minimum info.
A possible route of this is that the UI should keep a good cache so if the connection is lost, they still have thee info that they need. See how much data i need up front to have them using the app without a connection. (i.e. if i pull all address info on load, they can route with no connection. but how much data will that be up front? vs the one call for a lighter data set)
As long as we're subscribing to the socket instance from Angular, the mobile will automatically pick up the connection. There should be UI around disconnects tho so the user has some autonomy. Possibly a button to try and refresh.