Firebase-android-sdk: Firebase RealTime Database Socket connection error

Created on 11 Nov 2018  路  8Comments  路  Source: firebase/firebase-android-sdk

I am using fireabse real time database for my application. At times it it unable to form socket connection. But requests made to API hosted on firebase cloud-fucntion works properly.
I have used following dependencies :-

    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-database:16.0.3'
    implementation 'com.google.firebase:firebase-storage:16.0.3'
    implementation 'com.google.firebase:firebase-auth:16.0.4'

When I turned on the debug level it gives following :-

2018-11-11 14:13:17.932 14446-14513/com.example.com D/ConnectionRetryHelper: Scheduling retry in 933ms
2018-11-11 14:13:18.867 14446-14513/com.example.com D/PersistentConnection: pc_0 - Trying to fetch auth token
2018-11-11 14:13:18.873 14446-14513/com.example.com D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
2018-11-11 14:13:18.878 14446-14513/com.example.com D/Connection: conn_1 - Opening a connection
2018-11-11 14:13:48.881 14446-14513/com.example.com D/WebSocket: ws_1 - timed out on connect
2018-11-11 14:13:48.882 14446-14513/com.example.com D/WebSocket: ws_1 - closed
2018-11-11 14:13:48.882 14446-14513/com.example.com D/WebSocket: ws_1 - closing itself
2018-11-11 14:13:48.882 14446-14513/com.example.com D/Connection: conn_1 - Realtime connection failed
2018-11-11 14:13:48.882 14446-14513/com.example.com D/Connection: conn_1 - closing realtime connection

This keeps happening on certain device like Mi5 note pro, lenov

Most helpful comment

Getting the same error on Firebase Realtime database 16.1.0, it doesn't work on mobile network, but works perfectly fine on WiFi networks, also is much likely to happen on a device running Android 9.

Logs:

2019-03-18 16:21:12.138 D/WebSocket: ws_1 - timed out on connect
2019-03-18 16:21:12.139 D/WebSocket: ws_1 - closed
2019-03-18 16:21:12.139 D/WebSocket: ws_1 - closing itself
2019-03-18 16:21:12.139 D/Connection: conn_1 - Realtime connection failed
2019-03-18 16:21:12.139 D/Connection: conn_1 - closing realtime connection
2019-03-18 16:21:12.139 D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
2019-03-18 16:21:12.139 D/PersistentConnection: pc_0 - Scheduling connection attempt
2019-03-18 16:21:12.140 D/ConnectionRetryHelper: Scheduling retry in 539ms
2019-03-18 16:21:12.682 D/PersistentConnection: pc_0 - Trying to fetch auth token
2019-03-18 16:21:12.689 D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
2019-03-18 16:21:12.692 D/Connection: conn_2 - Opening a connection
2019-03-18 16:21:42.697 D/WebSocket: ws_2 - timed out on connect
2019-03-18 16:21:42.699 D/WebSocket: ws_2 - closed
2019-03-18 16:21:42.699 D/WebSocket: ws_2 - closing itself
2019-03-18 16:21:42.699 D/Connection: conn_2 - Realtime connection failed
2019-03-18 16:21:42.699 D/Connection: conn_2 - closing realtime connection
2019-03-18 16:21:42.700 D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
2019-03-18 16:21:42.700 D/PersistentConnection: pc_0 - Scheduling connection attempt
2019-03-18 16:21:42.702 D/ConnectionRetryHelper: Scheduling retry in 580ms
2019-03-18 16:21:43.284 D/PersistentConnection: pc_0 - Trying to fetch auth token
2019-03-18 16:21:43.287 D/PersistentConnection: pc_0 - Successfully fetched token, opening connection

The same snippet of message occurs in a loop.

All 8 comments

/assign @schmidt-sebastian
ptal

Issues like this in the past were device-specific problems with the local network stack. For debugging, we would need you to try to manually connect to the Firebase Host (which is specified in your google-services.json).

Since this issue has gone stale (sorry about that!), I am closing it for now. Let us know if it still persists.

I am still getting this issue in Android. I am using following libraries.
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation "com.google.firebase:firebase-database:16.1.0"
implementation "com.google.firebase:firebase-auth:16.1.0"

with custom Auth. https://firebase.google.com/docs/auth/android/custom-auth

Logs:
D/WebSocket: ws_0 - timed out on connect
D/WebSocket: ws_0 - closed
D/WebSocket: ws_0 - closing itself
D/Connection: conn_0 - Realtime connection failed
D/Connection: conn_0 - closing realtime connection
D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
D/PersistentConnection: pc_0 - Scheduling connection attempt
D/ConnectionRetryHelper: Scheduling retry in 675ms
D/PersistentConnection: pc_0 - Trying to fetch auth token
D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
D/Connection: conn_1 - Opening a connection
D/WebSocket: ws_1 - timed out on connect
D/WebSocket: ws_1 - closed
D/WebSocket: ws_1 - closing itself
D/Connection: conn_1 - Realtime connection failed
D/Connection: conn_1 - closing realtime connection
D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
D/PersistentConnection: pc_0 - Scheduling connection attempt
D/ConnectionRetryHelper: Scheduling retry in 1098ms
D/PersistentConnection: pc_0 - Trying to fetch auth token
D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
D/Connection: conn_2 - Opening a connection
D/WebSocket: ws_2 - timed out on connect
D/WebSocket: ws_2 - closed
D/WebSocket: ws_2 - closing itself
D/Connection: conn_2 - Realtime connection failed
D/Connection: conn_2 - closing realtime connection
D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
D/PersistentConnection: pc_0 - Scheduling connection attempt
D/ConnectionRetryHelper: Scheduling retry in 633ms
D/PersistentConnection: pc_0 - Trying to fetch auth token
D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
D/Connection: conn_3 - Opening a connection
D/WebSocket: ws_3 - timed out on connect
D/WebSocket: ws_3 - closed
D/WebSocket: ws_3 - closing itself
D/Connection: conn_3 - Realtime connection failed
D/Connection: conn_3 - closing realtime connection
D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
D/PersistentConnection: pc_0 - Scheduling connection attempt
D/ConnectionRetryHelper: Scheduling retry in 1399ms
D/PersistentConnection: pc_0 - Trying to fetch auth token
D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
D/Connection: conn_4 - Opening a connection

@anujjindal77 don't use implementation 'com.firebase:firebase-client-android:2.5.2' that's an extremely old library from pre-Google Firebase days!

Getting the same error on Firebase Realtime database 16.1.0, it doesn't work on mobile network, but works perfectly fine on WiFi networks, also is much likely to happen on a device running Android 9.

Logs:

2019-03-18 16:21:12.138 D/WebSocket: ws_1 - timed out on connect
2019-03-18 16:21:12.139 D/WebSocket: ws_1 - closed
2019-03-18 16:21:12.139 D/WebSocket: ws_1 - closing itself
2019-03-18 16:21:12.139 D/Connection: conn_1 - Realtime connection failed
2019-03-18 16:21:12.139 D/Connection: conn_1 - closing realtime connection
2019-03-18 16:21:12.139 D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
2019-03-18 16:21:12.139 D/PersistentConnection: pc_0 - Scheduling connection attempt
2019-03-18 16:21:12.140 D/ConnectionRetryHelper: Scheduling retry in 539ms
2019-03-18 16:21:12.682 D/PersistentConnection: pc_0 - Trying to fetch auth token
2019-03-18 16:21:12.689 D/PersistentConnection: pc_0 - Successfully fetched token, opening connection
2019-03-18 16:21:12.692 D/Connection: conn_2 - Opening a connection
2019-03-18 16:21:42.697 D/WebSocket: ws_2 - timed out on connect
2019-03-18 16:21:42.699 D/WebSocket: ws_2 - closed
2019-03-18 16:21:42.699 D/WebSocket: ws_2 - closing itself
2019-03-18 16:21:42.699 D/Connection: conn_2 - Realtime connection failed
2019-03-18 16:21:42.699 D/Connection: conn_2 - closing realtime connection
2019-03-18 16:21:42.700 D/PersistentConnection: pc_0 - Got on disconnect due to OTHER
2019-03-18 16:21:42.700 D/PersistentConnection: pc_0 - Scheduling connection attempt
2019-03-18 16:21:42.702 D/ConnectionRetryHelper: Scheduling retry in 580ms
2019-03-18 16:21:43.284 D/PersistentConnection: pc_0 - Trying to fetch auth token
2019-03-18 16:21:43.287 D/PersistentConnection: pc_0 - Successfully fetched token, opening connection

The same snippet of message occurs in a loop.

Still facing this issue!!

I am facing the exact same issue. I am using Firebase Real-time database 16.1.0. As far as I have observed this occurs on some devices when they are on mobile data. This issue is creating a lot of issues in the app.

Was this page helpful?
0 / 5 - 0 ratings