Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
Firebase Realtime Database concurrent connections reliability

I count the concurrent connections as follows:

onValue(ref(db, '.info/connected'), snapshot => {
            
    if (snapshot.val()) {

        let con = push(ref(db, 'concurrent'), { connected: moment().format('DD/MM/YYYY HH:mm') })

        onDisconnect(con).remove()

    }
}) 

However, when I check the database, I see connections from several days ago:

enter image description here

Does that mean that users have had inactive browser tabs since several days ago? Am I doing something wrong? Is the onDisconnect() function 100% reliable?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

firebaser here

Do you have security rules on the concurrent path that require the user to be authenticated by any chance? Because there's an open issue around that, which has been causing problems for more people recently.

Aside from that we haven't seen reliability issues in onDisconnect handling recently, so we'd need to see more information about the lingering connections (a stand-alone repro would be good).

about 4 years ago · Juan Pablo Isaza Denunciar

0

Reading the issue, it seems that if the tab is inactive for more than an hour, the token expires. If the tab is active again, Firebase client reconnects and gets a new token.

To remove the path in case of token expiration (idle tab):

const onIdleTabGoOffline = (ms) => {

    let timer

    document.addEventListener('visibilitychange', () => {

        if(document.hidden){

            timer = setTimeout(() => goOffline(db), ms)

        }
        else{

            clearTimeout(timer)

            goOnline(db)

        }

    })

} 

Finally:

onValue(ref(db, '.info/connected'), snapshot => {
    
    if (snapshot.val()) {

        let con = push(ref(db, 'concurrent'), { connected: moment().format('DD/MM/YYYY HH:mm') })

        onDisconnect(con).remove()

        onIdleTabGoOffline(59 * 60 * 1000)

    }
}) 
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda