I'm writing a Chrome background extension with firebase. What I've noticed is that when I hibernate my computer (Win7) while Chrome is open, the connection with firebase disconnects (as would be expected). However, when I return from hibernate it does not automatically reconnect and my .on() events are no longer firing.
I've already looked through the API documentation and this StackOverflow question about detecting disconnects: Detect if Firebase connection is lost/regained
Here's some pseudocode that I'm using to test the connection:
var myFirebase = new Firebase('https://my.firebaseio.com/'); //replace
setInterval(function() {
myFirebase.child('.info/connected').on('value', function (snap) {
if (snap.val() === true) {
console.log('Connected: ' + (new Date()).toString());
}
else {
console.log('Disconnected: ' + (new Date()).toString());
}
});
}, 5000);
This works as expected when running the javascript through a webpage - it connects, then disconnects when I hibernate, then reconnects soon after coming back from hibernation.
However, when it runs as a background page as part of a google extension, it disconnects and never reconnects.
Is there a way to force a reconnect and/or a reason why this isn't working as expected?