Losing connection with Firebase database after updating to new SDK

2,374 views
Skip to first unread message

Gideon

unread,
May 26, 2016, 10:27:50 AM5/26/16
to Firebase Google Group
After updating my projects Firebase SDK, I noticed my app regularly lose connection with the firebase database. The time it would take to disconnect ranging from a few minutes to just over an hour. Once disconnected, the app would not reconnect until I have either logged out or cleared the apps data.

Also right before I lose connection, an entry in the log states that my auth token has expired:

PersistentConnection: pc_0 - Auth token revoked: expired_token (Auth token is expired.)

FYI, im using Twitter and Facebook for my authentication and did not experience such issues with the previous Firebase SDK.

I created a new project (with simple auth and real time database) to see if the issue persists and it does.

Would anyone know what is causing the app to lose connection? So far the error has been experienced in 2 different projects with 2 auth providers (twitter and facebook) and only in the new SDK.

Code included in stackoverflow: https://stackoverflow.com/questions/37462087/losing-connection-with-firebase-database-after-updating-to-new-sdk

Scott Rossillo

unread,
May 26, 2016, 12:47:04 PM5/26/16
to Firebase Google Group
We're experiencing a similar issue using Google service account authentication:

FirebaseOptions options = new FirebaseOptions.Builder()
 
.setServiceAccount(new FileInputStream("path/to/serviceAccountCredentials.json"))
 
.setDatabaseUrl("https://databaseName.firebaseio.com/")
 
.build();

FirebaseApp.initializeApp(options);


 After some time, I see the error Gideon noted and all of my listeners stop receiving database update notification.

Kato Richardson

unread,
May 26, 2016, 1:43:59 PM5/26/16
to Firebase Google Group
Hi Gideon, Scott,

I also ran into this earlier today. But it went away after a short wait. Are you seeing it consistently? If you re-run the script does it persist?

Could you try turning on debug logging and sending us the output around the time of the failure, please?

firebase.database.enableLogging(true);

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/546b0c52-1cf8-45d8-9c54-ea14a7888190%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Scott Rossillo

unread,
May 26, 2016, 4:36:51 PM5/26/16
to Firebase Google Group
Code added. Let's wait and see.

FYI - in 3.0.0 the method is:

FirebaseDatabase.getInstance()..setLogLevel(Logger.Level.DEBUG);

Kato Richardson

unread,
May 26, 2016, 4:53:20 PM5/26/16
to Firebase Google Group
Oh interesting, I encountered it in Node.js. Do ping back if you get some debug logs. I'll try it there as well.


For more options, visit https://groups.google.com/d/optout.

Gideon

unread,
May 26, 2016, 8:07:59 PM5/26/16
to Firebase Google Group
I'll give it a shot and get back to you, thanks.

Gideon

unread,
May 28, 2016, 11:50:31 AM5/28/16
to Firebase Google Group
I found this after attaching enabling the debug logging:

D/PersistentConnection: pc_0 - Trying to fetch auth token
D
/PersistentConnection: pc_0 - Error fetching token: An internal error has occured. [ Token Service API has not been used in project myproject-1186 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/securetoken.googleapis.com/overview?project=linxey-1186 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. ]
D
/PersistentConnection: pc_0 - Scheduling connection attempt
D
/ConnectionRetryHelper: Scheduling retry in 2195ms

I followed the link to see if the Token Service API is enabled and it was enabled. So I'm not sure how to solve that issue.

On Thursday, 26 May 2016 19:43:59 UTC+2, Kato Richardson wrote:

Michael Lehenbauer

unread,
May 31, 2016, 2:39:09 PM5/31/16
to Firebase Google Group, Jin Liu, Cordelia Link
Very strange.  I'm adding a couple folks who may be more familiar with that error.

Jin Liu

unread,
May 31, 2016, 6:35:41 PM5/31/16
to Firebase Google Group, liu...@google.com, csl...@google.com
Hi Gideon,

Can you open a ticket to Firebase support, with a title like "Firebase Auth token expired" and link to this thread? Please include your project id in the ticket. We may need the read permission to your testing project, so I can take a look at your project settings.

Jin

Jean-Christophe SAKDAVONG

unread,
Jun 1, 2016, 10:58:37 AM6/1/16
to Firebase Google Group, liu...@google.com, csl...@google.com
I opened a ticket a few minutes ago... 

I will tell you if I get news !

JChris

Jean-Christophe SAKDAVONG

unread,
Jun 2, 2016, 10:38:07 AM6/2/16
to Firebase Google Group, liu...@google.com, csl...@google.com
I got news :-(...

I think that they hadn't the time to really read my ticket, because I got advices about configuring my Android App while it's a server issue....

I hope Jin Liu will to a better ready :-)

JChris

Gideon

unread,
Jun 2, 2016, 2:02:59 PM6/2/16
to Firebase Google Group, liu...@google.com, csl...@google.com
I opened a ticket a few days ago and they informed me that their aware of the bug and have a fix that will be released soon. You can track the issue here: https://status.firebase.google.com/incident/Authentication/16001
Message has been deleted
Message has been deleted

Jean-Christophe SAKDAVONG

unread,
Jun 3, 2016, 8:22:43 AM6/3/16
to Firebase Google Group, liu...@google.com, csl...@google.com
Jin, 
Could you erase your answer because I didn't realize that it was including my email address. 
Thanks
JChris

Le vendredi 3 juin 2016 03:50:25 UTC+2, Jin Liu a écrit :
Hi JChris,

I had assumed that your scenario is similar to the first post (lost connection after login with Twitter and Facebook), but later realized you were using server sdk. Server apps auth is a different issue and we are actively investigating that as well.

Jin

On Thursday, June 2, 2016 at 1:12:19 PM UTC-7, Jean-Christophe SAKDAVONG wrote:
It's the same as with me: They think it's an Android issue, when it's a server issue....

You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/_0zd6dgliEU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Jean-Christophe SAKDAVONG 
Maître de Conférence en Informatique et Chercheur en Psychologie Cognitive
Co-responsable du Master eFen à l'ESPE de Toulouse (E-Learning)

Département de Mathématiques-Informatique

Laboratoire Cognition, Langues, Langage, Ergonomie (CLLE-LTC)
Maison de la Recherche 
UMR CNRS-UT2JJ 5263
Axe "Rechercher, Apprendre, Décider"
Spécialisé en E-Learning/Recherche d'aide/Dispositifs NTIC et compétences métacognitives

Université Toulouse Jean-Jaurès
5, Allée A. Machado
31058 Toulouse Cedex 1

Jean-Christophe SAKDAVONG

unread,
Jun 3, 2016, 8:22:43 AM6/3/16
to Firebase Google Group, liu...@google.com, csl...@google.com
JChris

Le vendredi 3 juin 2016 03:50:25 UTC+2, Jin Liu a écrit :
Hi JChris,

I had assumed that your scenario is similar to the first post (lost connection after login with Twitter and Facebook), but later realized you were using server sdk. Server apps auth is a different issue and we are actively investigating that as well.

Jin

On Thursday, June 2, 2016 at 1:12:19 PM UTC-7, Jean-Christophe SAKDAVONG wrote:
It's the same as with me: They think it's an Android issue, when it's a server issue....

You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/_0zd6dgliEU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

Michael Lehenbauer

unread,
Jun 3, 2016, 3:23:11 PM6/3/16
to Firebase Google Group, Jin Liu, Cordelia Link
For folks having issues with the Java Server SDK (not Android), we've uncovered a bug in the 3.0.0 Firebase Java Server SDK where it can fail to re-authenticate to the Firebase Database backend. This will happen if your process runs longer than an hour and you don't have any active listeners (in particular at the one hour mark). You will see a [WARN] PersistentConnection: pc_0 - Authentication failed: invalid_token (Access denied.) error appear repeatedly in the console log.

We'll be releasing a new version (firebase-server-sdk 3.0.1) shortly with the fix. Until then, you can likely work around the issue by keeping an active listener (e.g. addValueEventListener() on a dummy location).

Sorry for the inconvenience! We'll try to get the fix out as soon as possible.

-Michael

Scott Rossillo

unread,
Jun 3, 2016, 5:33:00 PM6/3/16
to fireba...@googlegroups.com, Jin Liu, Cordelia Link
I had an active value event listener on a real location and that listener stopped getting updates after the error you mentioned.


~ Scott


Michael Lehenbauer

unread,
Jun 3, 2016, 6:17:45 PM6/3/16
to Firebase Google Group, Jin Liu, Cordelia Link
Thanks Scott,

That's interesting.  Would it be possible to enable database logging ("database.setLogLevel(LogLevel.DEBUG);") and send me (mike...@google.com) a complete log of your server hitting the issue?  Based on your error message, I'm pretty sure our fix will address your case but I'm a bit surprised you hit that error.

For context, the issue we fixed is as follows: If the client's auth token expires when it's not connected to the Firebase Database backend, it won't properly refresh the token and will just send the same expired token when it connects again.  But if you have an active listener, you *should* maintain a constant connection to the server, and in that case when the token expires we will correctly refresh it.

Any chance your "server" code was running on a laptop or something with an unreliable connection and so it might not have been connected when the token expired?

Anyway, if you can send me the log, I should be able to tell for sure.  Else, if you wait until we get the fix out, you can check if it resolves it.

Thanks!
-Michael

Michael Lehenbauer

unread,
Jun 6, 2016, 5:55:25 PM6/6/16
to Firebase Google Group
We've released the 3.0.1 version of the Firebase Server SDK which contains the fix.  If you were hitting this error, please give it a try and report back if you're still hitting issues.

Thanks!
-Michael
Reply all
Reply to author
Forward
0 new messages