Firestore + Realtime Database: presence comes to offline after a minute and never turn back online...












0
















This question already has an answer here:




  • Android - Firestore/Firebase Realtime Database “.info/connected” returns wrong connection state

    1 answer




I build application with firestore, react-native and react-native-firestore. Now I use only firestore in my project. I want to implement presence for that app, and found solution: https://firebase.google.com/docs/firestore/solutions/presence?authuser=0



I started by writing simple code:



firebase.database().ref(".info/connected").on("value", snap => {
console.log(".info/connected", snap.val());
});


just to test how it works.



It outputs this



11-21 14:48:03.117  6502  6571 I ReactNativeJS: '.info/connected', false
11-21 14:48:03.710 6502 6571 I ReactNativeJS: '.info/connected', true
11-21 14:49:02.892 6502 6571 I ReactNativeJS: '.info/connected', false


As you can see, right after application startup, connected status becomes true within a second. But after ~1 minute, it becomes false and never goes back to true. Meanwhile application is fully operate, queries sent to firestore succesfully finished and etc.



I think it happens because I actually do not perform any query to Realtime Database. Am I right?










share|improve this question















marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 14:48


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    You are correct: if you don't listen for any other data, the Firebase SDK will auto-close its connection to the Realtime Database after a minute. To prevent this, add a separate listener to the root of the empty database, for example by calling firebase.database().ref().keepSynced(true). This is a known issue in the documentation. See stackoverflow.com/questions/53320480/…

    – Frank van Puffelen
    Nov 21 '18 at 14:45


















0
















This question already has an answer here:




  • Android - Firestore/Firebase Realtime Database “.info/connected” returns wrong connection state

    1 answer




I build application with firestore, react-native and react-native-firestore. Now I use only firestore in my project. I want to implement presence for that app, and found solution: https://firebase.google.com/docs/firestore/solutions/presence?authuser=0



I started by writing simple code:



firebase.database().ref(".info/connected").on("value", snap => {
console.log(".info/connected", snap.val());
});


just to test how it works.



It outputs this



11-21 14:48:03.117  6502  6571 I ReactNativeJS: '.info/connected', false
11-21 14:48:03.710 6502 6571 I ReactNativeJS: '.info/connected', true
11-21 14:49:02.892 6502 6571 I ReactNativeJS: '.info/connected', false


As you can see, right after application startup, connected status becomes true within a second. But after ~1 minute, it becomes false and never goes back to true. Meanwhile application is fully operate, queries sent to firestore succesfully finished and etc.



I think it happens because I actually do not perform any query to Realtime Database. Am I right?










share|improve this question















marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 14:48


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    You are correct: if you don't listen for any other data, the Firebase SDK will auto-close its connection to the Realtime Database after a minute. To prevent this, add a separate listener to the root of the empty database, for example by calling firebase.database().ref().keepSynced(true). This is a known issue in the documentation. See stackoverflow.com/questions/53320480/…

    – Frank van Puffelen
    Nov 21 '18 at 14:45
















0












0








0









This question already has an answer here:




  • Android - Firestore/Firebase Realtime Database “.info/connected” returns wrong connection state

    1 answer




I build application with firestore, react-native and react-native-firestore. Now I use only firestore in my project. I want to implement presence for that app, and found solution: https://firebase.google.com/docs/firestore/solutions/presence?authuser=0



I started by writing simple code:



firebase.database().ref(".info/connected").on("value", snap => {
console.log(".info/connected", snap.val());
});


just to test how it works.



It outputs this



11-21 14:48:03.117  6502  6571 I ReactNativeJS: '.info/connected', false
11-21 14:48:03.710 6502 6571 I ReactNativeJS: '.info/connected', true
11-21 14:49:02.892 6502 6571 I ReactNativeJS: '.info/connected', false


As you can see, right after application startup, connected status becomes true within a second. But after ~1 minute, it becomes false and never goes back to true. Meanwhile application is fully operate, queries sent to firestore succesfully finished and etc.



I think it happens because I actually do not perform any query to Realtime Database. Am I right?










share|improve this question

















This question already has an answer here:




  • Android - Firestore/Firebase Realtime Database “.info/connected” returns wrong connection state

    1 answer




I build application with firestore, react-native and react-native-firestore. Now I use only firestore in my project. I want to implement presence for that app, and found solution: https://firebase.google.com/docs/firestore/solutions/presence?authuser=0



I started by writing simple code:



firebase.database().ref(".info/connected").on("value", snap => {
console.log(".info/connected", snap.val());
});


just to test how it works.



It outputs this



11-21 14:48:03.117  6502  6571 I ReactNativeJS: '.info/connected', false
11-21 14:48:03.710 6502 6571 I ReactNativeJS: '.info/connected', true
11-21 14:49:02.892 6502 6571 I ReactNativeJS: '.info/connected', false


As you can see, right after application startup, connected status becomes true within a second. But after ~1 minute, it becomes false and never goes back to true. Meanwhile application is fully operate, queries sent to firestore succesfully finished and etc.



I think it happens because I actually do not perform any query to Realtime Database. Am I right?





This question already has an answer here:




  • Android - Firestore/Firebase Realtime Database “.info/connected” returns wrong connection state

    1 answer








javascript firebase firebase-realtime-database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 14:49









Frank van Puffelen

240k29383410




240k29383410










asked Nov 21 '18 at 11:55









Artur EshenbrenerArtur Eshenbrener

695819




695819




marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 14:48


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Frank van Puffelen firebase
Users with the  firebase badge can single-handedly close firebase questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 14:48


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    You are correct: if you don't listen for any other data, the Firebase SDK will auto-close its connection to the Realtime Database after a minute. To prevent this, add a separate listener to the root of the empty database, for example by calling firebase.database().ref().keepSynced(true). This is a known issue in the documentation. See stackoverflow.com/questions/53320480/…

    – Frank van Puffelen
    Nov 21 '18 at 14:45
















  • 1





    You are correct: if you don't listen for any other data, the Firebase SDK will auto-close its connection to the Realtime Database after a minute. To prevent this, add a separate listener to the root of the empty database, for example by calling firebase.database().ref().keepSynced(true). This is a known issue in the documentation. See stackoverflow.com/questions/53320480/…

    – Frank van Puffelen
    Nov 21 '18 at 14:45










1




1





You are correct: if you don't listen for any other data, the Firebase SDK will auto-close its connection to the Realtime Database after a minute. To prevent this, add a separate listener to the root of the empty database, for example by calling firebase.database().ref().keepSynced(true). This is a known issue in the documentation. See stackoverflow.com/questions/53320480/…

– Frank van Puffelen
Nov 21 '18 at 14:45







You are correct: if you don't listen for any other data, the Firebase SDK will auto-close its connection to the Realtime Database after a minute. To prevent this, add a separate listener to the root of the empty database, for example by calling firebase.database().ref().keepSynced(true). This is a known issue in the documentation. See stackoverflow.com/questions/53320480/…

– Frank van Puffelen
Nov 21 '18 at 14:45














1 Answer
1






active

oldest

votes


















0














You should implement the Logic for realTime Database, an then you need use CloudFunctions to keep Realtime Database and Cloud Firestore in sync. it is the only way. have you ever used cloud functions in the past?






share|improve this answer
























  • No, I build slightly different case, and I do not need the whole power of presence. I want to indicate end user that connection is lost (and remove indicator when connection restores).

    – Artur Eshenbrener
    Nov 21 '18 at 12:45











  • but internet connection do you mean?

    – Helmer Barcos
    Nov 21 '18 at 12:47











  • Not only internet connection - connection to firebase servers. Becuase internet connection is generally available, but firebase servers may be not reachable.

    – Artur Eshenbrener
    Nov 22 '18 at 11:44


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You should implement the Logic for realTime Database, an then you need use CloudFunctions to keep Realtime Database and Cloud Firestore in sync. it is the only way. have you ever used cloud functions in the past?






share|improve this answer
























  • No, I build slightly different case, and I do not need the whole power of presence. I want to indicate end user that connection is lost (and remove indicator when connection restores).

    – Artur Eshenbrener
    Nov 21 '18 at 12:45











  • but internet connection do you mean?

    – Helmer Barcos
    Nov 21 '18 at 12:47











  • Not only internet connection - connection to firebase servers. Becuase internet connection is generally available, but firebase servers may be not reachable.

    – Artur Eshenbrener
    Nov 22 '18 at 11:44
















0














You should implement the Logic for realTime Database, an then you need use CloudFunctions to keep Realtime Database and Cloud Firestore in sync. it is the only way. have you ever used cloud functions in the past?






share|improve this answer
























  • No, I build slightly different case, and I do not need the whole power of presence. I want to indicate end user that connection is lost (and remove indicator when connection restores).

    – Artur Eshenbrener
    Nov 21 '18 at 12:45











  • but internet connection do you mean?

    – Helmer Barcos
    Nov 21 '18 at 12:47











  • Not only internet connection - connection to firebase servers. Becuase internet connection is generally available, but firebase servers may be not reachable.

    – Artur Eshenbrener
    Nov 22 '18 at 11:44














0












0








0







You should implement the Logic for realTime Database, an then you need use CloudFunctions to keep Realtime Database and Cloud Firestore in sync. it is the only way. have you ever used cloud functions in the past?






share|improve this answer













You should implement the Logic for realTime Database, an then you need use CloudFunctions to keep Realtime Database and Cloud Firestore in sync. it is the only way. have you ever used cloud functions in the past?







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 12:03









Helmer BarcosHelmer Barcos

634310




634310













  • No, I build slightly different case, and I do not need the whole power of presence. I want to indicate end user that connection is lost (and remove indicator when connection restores).

    – Artur Eshenbrener
    Nov 21 '18 at 12:45











  • but internet connection do you mean?

    – Helmer Barcos
    Nov 21 '18 at 12:47











  • Not only internet connection - connection to firebase servers. Becuase internet connection is generally available, but firebase servers may be not reachable.

    – Artur Eshenbrener
    Nov 22 '18 at 11:44



















  • No, I build slightly different case, and I do not need the whole power of presence. I want to indicate end user that connection is lost (and remove indicator when connection restores).

    – Artur Eshenbrener
    Nov 21 '18 at 12:45











  • but internet connection do you mean?

    – Helmer Barcos
    Nov 21 '18 at 12:47











  • Not only internet connection - connection to firebase servers. Becuase internet connection is generally available, but firebase servers may be not reachable.

    – Artur Eshenbrener
    Nov 22 '18 at 11:44

















No, I build slightly different case, and I do not need the whole power of presence. I want to indicate end user that connection is lost (and remove indicator when connection restores).

– Artur Eshenbrener
Nov 21 '18 at 12:45





No, I build slightly different case, and I do not need the whole power of presence. I want to indicate end user that connection is lost (and remove indicator when connection restores).

– Artur Eshenbrener
Nov 21 '18 at 12:45













but internet connection do you mean?

– Helmer Barcos
Nov 21 '18 at 12:47





but internet connection do you mean?

– Helmer Barcos
Nov 21 '18 at 12:47













Not only internet connection - connection to firebase servers. Becuase internet connection is generally available, but firebase servers may be not reachable.

– Artur Eshenbrener
Nov 22 '18 at 11:44





Not only internet connection - connection to firebase servers. Becuase internet connection is generally available, but firebase servers may be not reachable.

– Artur Eshenbrener
Nov 22 '18 at 11:44





這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini