【问题标题】:firebase realtime database client is offline [closed]firebase实时数据库客户端离线[关闭]
【发布时间】:2022-01-17 09:08:04
【问题描述】:

当我在 firebase 数据库中搜索数据时,我收到了此错误消息。客户端离线。 我该如何解决?

//2022-01-16 21:42:34.589 29418-29624/com.lepetitprincess.pointcard I/RepoOperation:获取查询 /issuers/iyGGn9JHdpYGR0YEWXMxOMtTH0s1/account 错误后回退到磁盘缓存:客户端离线 //2022-01-16 21:42:34.813 29418-29418/com.lepetitprincess.pointcard E/firebase:获取数据时出错 //java.lang.Exception: 客户端离线 //在 com.google.firebase.database.connection.PersistentConnectionImpl.lambda$get$1$com-google-firebase-database-connection-PersistentConnectionImpl(PersistentConnectionImpl.java:441) //在 com.google.firebase.database.connection.PersistentConnectionImpl$$ExternalSyntheticLambda4.run(未知来源:8) //在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) //在 java.util.concurrent.FutureTask.run(FutureTask.java:266) //在 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) //在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) //在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) //at java.lang.Thread.run(Thread.java:764)

【问题讨论】:

  • 您是否尝试过检查数据是否存在?附上您的代码,以便我们更好地帮助您。 if(database.snapshot.child("somthing").exist()){//TODO}

标签: android firebase kotlin firebase-realtime-database


【解决方案1】:

我遇到了同样的问题,我通过创建应用程序类并将数据库的持久性设置更改为启用来修复它:

class MyApplication : Application() {
  override fun onCreate() {
    super.onCreate()
    Firebase.database.setPersistenceEnabled(true)
    }
}

别忘了在清单文件中设置应用程序类:

android:name=".MyApplication"

【讨论】:

    猜你喜欢
    • 2021-12-10
    • 2021-10-30
    • 2017-08-06
    • 1970-01-01
    • 2021-05-01
    • 1970-01-01
    • 2018-12-29
    • 2018-03-18
    • 2021-08-10
    相关资源
    最近更新 更多