首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FirebaseRemoteConfigClientException on production (安卓)

FirebaseRemoteConfigClientException on production (安卓)
EN

Stack Overflow用户
提问于 2020-03-09 07:06:34
回答 1查看 5.6K关注 0票数 1

到目前为止我做了什么.

我使用Tasks.await 阻塞机制在工作线程中调用防火墙,以避免回调。

我正在使用一个工作线程(JobIntentService)进行一些初始化过程。当应用程序打开并且只运行一次时,JobIntentService就会启动。下面是我的工作线程代码

代码语言:javascript
复制
    if (isDeviceConnectedToInternet()) {
        Tasks.await(FirebaseConfigHelper.getRemoteConfig().fetchAndActivate()); //error here
        initFirebaseConfigVariables();
        // other codes
    }

//FirebaseConfigHelper.java
public static FirebaseRemoteConfig getRemoteConfig() {
    FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
    mFirebaseRemoteConfig.setDefaultsAsync(R.xml.remote_config_defaults);
    return mFirebaseRemoteConfig;
}

我在用

代码语言:javascript
复制
implementation 'com.google.firebase:firebase-config:19.0.4'

关于错误

它在测试设备上工作得很好。我用火源测试实验室测试了另外15台设备。根本没有任何问题。但是当我发布到生产时,这个错误发生在一些特定的Mi和Samsung设备上。

错误日志

我只能得到这个日志,因为在生产中会发生错误。

代码语言:javascript
复制
java.util.concurrent.ExecutionException:
com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException:
The client had an error while calling the backend!  at
com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)   at
com.google.android.gms.tasks.Tasks.await(Unknown Source:23) at
com.maju.myapp.service.SyncWithFirebaseJobIntentService.syncWithFirebaseConfig(SyncWithFirebaseJobIntentService.java:207)   at
com.maju.myapp.service.SyncWithFirebaseJobIntentService.onHandleWork(SyncWithFirebaseJobIntentService.java:55)  at
androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:392)   at
androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:383)   at
android.os.AsyncTask$3.call(AsyncTask.java:378) at
java.util.concurrent.FutureTask.run(FutureTask.java:266)    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at
java.lang.Thread.run(Thread.java:919)Caused by:
com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException:
The client had an error while calling the backend!  at
com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient.fetch(com.google.firebase:firebase-config@@19.0.4:194)  at
com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackend(com.google.firebase:firebase-config@@19.0.4:278)  at
com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackendAndCacheResponse(com.google.firebase:firebase-config@@19.0.4:251)  at
com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchIfCacheExpiredAndNotThrottled(com.google.firebase:firebase-config@@19.0.4:191)    at
com.google.firebase.remoteconfig.internal.ConfigFetchHandler.lambda$fetch$0(com.google.firebase:firebase-config@@19.0.4:160)    at
com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$Lambda$1.then(Unknown
Source:4)   at com.google.android.gms.tasks.zzf.run(Unknown
Source:2)   ... 3 moreCaused by: java.net.ConnectException: Failed to
connect to
firebaseremoteconfig.googleapis.com/2404:6800:4007:809::200a:443    at
com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:147)    at
com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)  at
com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186) at
com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)  at
com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)   at
com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)    at
com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)    at
com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)   at
com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)   at
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:262)   at
com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:219) at
com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:30)  at
com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient.setFetchRequestBody(com.google.firebase:firebase-config@@19.0.4:321)    at
com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient.fetch(com.google.firebase:firebase-config@@19.0.4:182)  ...
9 more
  1. 为什么会发生这种事?
  2. 如何避免呢?

(回调使代码变得丑陋和凌乱,为了编写干净的代码,我更喜欢Tasks.await)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-30 14:30:18

我联系了这个问题的Firebase支持

他们说

如果设备用户的连接在我们的SDK试图调用数据获取时出现问题,并且会导致“客户机在调用后端!时出错”,则会发生这种情况。这样看来,在获取远程配置数据之前,您正在对最近更新中的连接进行验证。您可以检查我们的实现这里,您可以可视化我们的调用来触发这个问题。 您可以使用Android网络调试器模拟网络调用,这样就可以捕获处理机制,以确保实际设备在进行获取时具有适当的连接性。

所以问题可能是设备的网络连接。我检查最近更新的网络连接情况。但我还是会在一些设备中发现这个错误。原因可能是设备的连接质量不佳(@Tash Pemhiwa在评论中建议)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60595972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档