Firebase.database.getReference(".info/connected") not working
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
調査の方向性
issue の Kotlin スニペットにある FirebaseConnection.checkConnection と .info/connected の ValueEventListener から始めます。指定された SDK バージョンを使用し、記載されている Xiaomi Redmi Note 10s および Android 12 の環境で切断を再現してから、データベースの読み取りと併せて接続コールバックを調査します。原因を再現でき、接続処理によって報告された読み取りとアップロードが妨げられなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Step 1: Describe your environment
- Android device: Xiaomi Redmi Note 10s
- Android OS version: 12
- Google Play Services version: 1.37 (my cellphone)
- Firebase/Play Services SDK version: 31.1.1 && 4.3.14
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:
- What happened? This could be a description,
logcatoutput, 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
}
}
- 主要言語
- Kotlin
- スター
- 9.3k
- フォーク
- 7.4k
- 平均マージ
- 7日 9時間
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firebase/quickstart-android のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
firebase/quickstart-android#2756 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
firebase/quickstart-android#2754 · コメント 5 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
firebase/quickstart-android#2668 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
firebase/quickstart-android#2663 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
firebase/quickstart-android#1669 · コメント 3 件 ·
firebase/quickstart-android の issue をすべて見る
似ている issue
-
android:plan main:plan packages:learn
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
afk-ok area:data-quality importer size:S
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
enorm-labs/event-junkie#5278 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
LeanBitLab/LeanType#864 ·
メンテナーはふだん 1 日以内に返信
-
Comment NEW RI+MC+RR
難易度 1/5 1〜3時間 初心者へのやさしさ 70/100