You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an app that uses Realtime Database, and I need to handle connection errors so I use Firebase.database.getReference(".info/connected") to know when I'm connected and when I'm not. everything works fine when i start or restart the app, but about a minute (sometimes more, never less) it disconnects from firebase, and the connection is always negative, i can't upload scores (i have a quiz) or make queries, it just disconnects without apparent reason.
Steps to reproduce:
Observed Results:
What happened? This could be a description, logcat output, etc.
At some point in the life cycle of the application in the logcate it appears to me that it has been disconnected for no reason, even without doing anything in the application, this logcat simply appears:
023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callback getSinglerecordByUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callback getSinglerecordByUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W callback getSinglerecordByUid: false
Expected Results:
What did you expect to happen?
Relevant Code:
// TODO(you): code here to reproduce the problem
class FirebaseConnection {
private var connected: Boolean = false
fun checkConnection(callback: (Boolean) -> Unit) {
val connectedRef = Firebase.database.getReference(".info/connected")
connectedRef.addValueEventListener(object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
val isConnected:Boolean? = snapshot.getValue(Boolean::class.java)
if (isConnected == true) {
connected = true
Log.w(TAG, "my Class: connected")
} else if(isConnected == false){
Log.w(TAG, "my Class: not connected")
connected = false
}
callback(connected)
}
override fun onCancelled(error: DatabaseError) {
Log.w(TAG, "Listener was cancelled")
callback(false)
}
})
}
}
override suspend fun getSingleRecordByUid(uid: String, typeRec: String): DataSnapshot? {
return withContext(Dispatchers.IO){
val myClass = FirebaseConnection()
var connection: Boolean? = null
myClass.checkConnection { isConnected ->
Log.w(TAG, "callback getSinglerecordByUid: $isConnected")
connection = isConnected
}
while (connection == null) {
// Esperar hasta que se complete la llamada de retorno
delay(10)
}
if(connection as Boolean) userInstance.child(uid).child(typeRec).get().await() else null
}
}
The text was updated successfully, but these errors were encountered:
Step 1: Describe your environment
Step 2: Describe the problem:
I have an app that uses Realtime Database, and I need to handle connection errors so I use Firebase.database.getReference(".info/connected") to know when I'm connected and when I'm not. everything works fine when i start or restart the app, but about a minute (sometimes more, never less) it disconnects from firebase, and the connection is always negative, i can't upload scores (i have a quiz) or make queries, it just disconnects without apparent reason.
Steps to reproduce:
Observed Results:
logcat
output, etc.At some point in the life cycle of the application in the logcate it appears to me that it has been disconnected for no reason, even without doing anything in the application, this logcat simply appears:
023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callback getSinglerecordByUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callback getSinglerecordByUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.348 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W callbackgetUserData byUid: false
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W my Class: not connected
2023-05-24 14:08:45.349 18112-18112 ContentValues com.example.geoquizmx W callback getSinglerecordByUid: false
Expected Results:
Relevant Code:
The text was updated successfully, but these errors were encountered: