Database (Android) stop refreshing after couple of hours (not "Error fetching token" problem)

334 views
Skip to first unread message

Miroslav Kuzmisin

unread,
Aug 7, 2016, 10:55:53 AM8/7/16
to Firebase Google Group
Hi all,

after couple of hours (typically over night) application stop receiving update from database (PERSISTANCE enabled). After that, if I keep application running (and wakeup, screen on, connected to ADB), after 10 minutes start working again (no problem with internet connection, all other app/requests works).

I am not using auth module, application is full anonymous. This problem is only for Android 6 (Android 4 and iOS works OK)

I am not getting "Error fetching token" in logcat as it is mentioned in many posts, anyway I've made all setup with SHA1 keys in firebase console and google console (Android 4 and iOS just works). And also I can not call "user.getToken(true).addOnCompleteListener" because I don't have an user.

For me it looks like, that WS connection did not receive timeout for re-establish connection.

please, any ideas where is the problem?
thanks

Android 6 (Nexus 9)
com.google.firebase:firebase-database:9.4.0

Log:

// START - getting "old" data (from persistence)
08-07 09:51:05.989 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: -6

// ... OTHER LOGS, stil not working

08-07 09:55:01.234 25315-27586/com.app D/Persistence: Transaction completed. Elapsed: 19ms
08-07 09:55:01.234 25315-27586/com.app D/Persistence: Starting transaction.
08-07 09:55:01.235 25315-27586/com.app D/Persistence: Transaction completed. Elapsed: 0ms
08-07 09:55:46.220 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: 0
08-07 09:56:31.222 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: 0
08-07 09:57:16.222 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: 0
08-07 09:58:01.224 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: -1
08-07 09:58:46.225 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: 0
08-07 09:59:31.226 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: 0
08-07 10:00:16.227 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: 0
08-07 10:01:01.234 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: -5
08-07 10:01:46.235 25315-27586/com.app D/WebSocket: ws_34 - Reset keepAlive. Remaining: 0

// START WORKING AGAIN
08-07 10:02:29.761 25315-27586/com.app D/WebSocket: ws_34 - had an error
                                                          byk: IO Error
                                                              at byn.a(:com.google.android.gms.DynamiteModulesC:78)
                                                              at bye.d(:com.google.android.gms.DynamiteModulesC:371)
                                                              at byg.run(:com.google.android.gms.DynamiteModulesC:1028)
                                                              at java.lang.Thread.run(Thread.java:818)
                                                           Caused by: javax.net.ssl.SSLException: Read error: ssl=0x55a01ac3d0: I/O error during system call, Connection timed out
                                                              at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
                                                              at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:705)
                                                              at libcore.io.Streams.readFully(Streams.java:81)
                                                              at java.io.DataInputStream.readFully(DataInputStream.java:99)
                                                              at byn.a(:com.google.android.gms.DynamiteModulesC:141)
                                                              at byn.a(:com.google.android.gms.DynamiteModulesC:34)
                                                              at bye.d(:com.google.android.gms.DynamiteModulesC:371) 
                                                              at byg.run(:com.google.android.gms.DynamiteModulesC:1028) 
                                                              at java.lang.Thread.run(Thread.java:818) 
08-07 10:02:29.762 25315-27586/com.app D/WebSocket: ws_34 - |IO Error|
08-07 10:02:29.762 25315-27586/com.app D/WebSocket: ws_34 - closing itself
08-07 10:02:29.763 25315-27586/com.app D/Connection: conn_34 - Realtime connection lost
08-07 10:02:29.764 25315-27586/com.app D/Connection: conn_34 - closing realtime connection
08-07 10:02:29.764 25315-27586/com.app D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
08-07 10:02:29.764 25315-27586/com.app D/PersistentConnection: pc_0 - Scheduling connection attempt
08-07 10:02:29.764 25315-27586/com.app D/ConnectionRetryHelper: Scheduling retry in 0ms
08-07 10:02:29.771 25315-27586/com.app D/WebSocket: ws_34 - had an error
                                                          byk: IO Exception
                                                              at byo.a(:com.google.android.gms.DynamiteModulesC:148)
                                                              at byp.run(:com.google.android.gms.DynamiteModulesC:1022)
                                                              at java.lang.Thread.run(Thread.java:818)
                                                           Caused by: javax.net.ssl.SSLException: Write error: ssl=0x55a01ac3d0: I/O error during system call, Broken pipe
                                                              at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
                                                              at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:771)
                                                              at java.nio.channels.Channels$OutputStreamChannel.write(Channels.java:348)
                                                              at byo.b(:com.google.android.gms.DynamiteModulesC:127)
                                                              at byo.a(:com.google.android.gms.DynamiteModulesC:141)
                                                              at byp.run(:com.google.android.gms.DynamiteModulesC:1022) 
                                                              at java.lang.Thread.run(Thread.java:818) 
08-07 10:02:29.771 25315-27586/com.app D/WebSocket: ws_34 - |IO Exception|
08-07 10:02:29.772 25315-27586/com.app D/WebSocket: ws_34 - closed
08-07 10:02:29.772 25315-27586/com.app D/PersistentConnection: pc_0 - Trying to fetch auth token
08-07 10:02:29.774 25315-27586/com.app D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
08-07 10:02:29.776 25315-27586/com.app D/Connection: conn_35 - Opening a connection
08-07 10:02:30.418 25315-27586/com.app D/WebSocket: ws_35 - websocket opened
08-07 10:02:30.419 25315-27586/com.app D/WebSocket: ws_35 - Reset keepAlive
08-07 10:02:30.423 25315-6647/com.app D/WebSocket: ws_35 - ws message: {***}
08-07 10:02:30.423 25315-27586/com.app D/WebSocket: ws_35 - Reset keepAlive. Remaining: 44995
08-07 10:02:30.424 25315-27586/com.app D/WebSocket: ws_35 - HandleNewFrameCount: 1
08-07 10:02:30.425 25315-27586/com.app D/WebSocket: ws_35 - handleIncomingFrame complete frame: {***}
08-07 10:02:30.426 25315-27586/com.app D/Connection: conn_35 - Got control message: {***}
08-07 10:02:30.426 25315-27586/com.app D/Connection: conn_35 - realtime connection established

Miroslav Kuzmisin

unread,
Aug 8, 2016, 2:50:55 PM8/8/16
to Firebase Google Group
... please, nobody has an idea where can be the problem, or what I can try?

Michael Lehenbauer

unread,
Aug 8, 2016, 4:12:36 PM8/8/16
to Firebase Google Group
Hey Miroslav,

So if I understood correctly, after leaving the app running for a long time, it will stop receiving Firebase Database updates, but if you wait ~10min then it'll start working again?

This sounds like our socket connection is dying in an unclean way (i.e. the OS isn't notifying us that the TCP connection is dead, but it is so it takes a long time for us to detect it and create a new connection).  These sorts of problems are notoriously hard to track down and they can be caused by weird stuff going on in the OS (proxy settings, etc.) or with your network connection (wifi router, cell provider, etc.).  

You might experiment with other networks (a different wifi network, or try cell if you're doing wifi) and see if the behavior changes.

Or, as a workaround, if you can detect when you're in this state you could forcefully kill/restart the connection with FirebaseDatabase.getInstance().goOffline() / goOnline().

Sorry I don't have a better answer, but maybe this helps...
-Michael

--
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-talk+unsubscribe@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/ef6a0d66-f52e-42f2-8344-fea1b135c04c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Miroslav Kuzmisin

unread,
Aug 9, 2016, 10:21:54 AM8/9/16
to Firebase Google Group
Hi Michael,

workaround with FirebaseDatabase.getInstance().goOffline() / goOnline() works

If you will have any idea, what I can try to help you investigate cause of problem, just let me know and I'll try it ... (for example, some custom "com.google.firebase:firebase-database" package with extended/verbose log, which log everything what package doing and what getting from system)

thanks again
Miro
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Miroslav Kuzmisin

unread,
Aug 9, 2016, 10:22:03 AM8/9/16
to Firebase Google Group
Hi Michael,

> after leaving the app running for a long time, it will stop receiving Firebase Database updates, but if you wait ~10min then it'll start working again?
yes, exactly

> OS (proxy settings, etc.) or with your network connection (wifi router, cell provider, etc.)
> other networks (a different wifi network, or try cell if you're doing wifi) and see if the behavior changes.
I have only Nexus 9 with Adnroid 6 and Nexus 9 has no cell, no proxy in my network, but I'll try to send application to test users to get more information about problem

> as a workaround, ... goOffline() / goOnline()
I'll try it and let you know

many thanks
Miro

On Monday, August 8, 2016 at 10:12:36 PM UTC+2, Michael Lehenbauer wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages