简体   繁体   中英

Change Firebase real time database ping pong time

a query related to firebase presence app using javascript sdk. I have seen that there is 60 seconds buffer after the inte.net is disconnected after which the entries are removed from the firebase real tim edatabase. Is it possible to configure this time from 60 seconds to lets say 30 seconds? . I basically want the entries to be removed from the presence as soon as the inte.net is disconnected. If not immediately then at least sooner than a minute alteast.Does anybody have any idea on this?

There are two ways an onDisconnect handler can be triggered on the Firebase servers:

  • A clean disconnect is when the client has time to inform the server that it is about to disconnect, and in that case the server executes the onDisconnect handlers immediately.
  • A dirty disconnect is when the client disconnects without informing the server. In this case the server detects that the client is gone when the socket from that client times out, and then it executes the onDisconnect handlers.

Detecting the dirty disconnects takes some times (upwards to a few minutes) and there's no way for you to configure it.


If you want more granular presence detection, the common approach is to periodically write a timestamp into the database from the client. This indicates when the client was last active, and can be used by the other clients to then indicate the liveliness of that user/client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM