Keeping long term stream open with custom tokens #644
-
Hi, I'm working on a project where I need a RTDB stream to be open and listening at all times. I am getting a custom token from my API and logging in just fine, then beginning a stream. It works perfectly for exactly 55 minutes each time until (I think this is the problem) the token expires, then no more changes on the node are detected. I've tried setting |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
When custom token expired before the 60 minutes after Unfortunately, the function Normally, the stream time out should be occurred unless your code stops at some points. We can't refresh the token because of no refresh token provided then You have to call This is better if you provide the refresh token to The refresh token itself is never expired and you can use it many times. |
Beta Was this translation helpful? Give feedback.
-
I recommend you set custom token with After 30 minutes or whenever you want, call The token is now will be refresh automatically. After your device reboot, you can read the refresh token from file and set it to |
Beta Was this translation helpful? Give feedback.
I recommend you set custom token with
setCustomToken
only one time, and when token is ready (Firebase.ready
), you save the refresh token fromFirebase.getRefreshToken()
as file.After 30 minutes or whenever you want, call
setCustomToken
again with the refresh token and setconfig.signer.preRefreshSeconds
to 30 minutes or any.The token is now will be refresh automatically.
After your device reboot, you can read the refresh token from file and set it to
setCustomToken
which custom token will not be required anymore.