【发布时间】:2021-10-26 05:07:10
【问题描述】:
从昨天 (2021.10.25) 开始,我的应用在连接到 LTE 时就没有连接到 Firebase。 我已经在使用多个不同电话网络提供商的多台设备上进行了尝试。
更具体地说,在下面的代码中,我们转到“Log task unsuccessful”的情况。
FirebaseFirestore db = FirebaseFirestore.getInstance();
DocumentReference docRef = db.collection("Version").document("MinVersion");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
//Do stuff here
}
} else {
//Log task unsuccessful
}
}
});
当我打开 wifi 时,firebase 会立即连接。
可能有用的日志:
W/Firestore: (23.0.4) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
(但是,互联网连接良好 - 一旦应用程序加载,广告工作正常,网络浏览器工作正常等 - 只有 firestore 不工作)
这可能是什么原因造成的?我住在韩国,昨天我们最大的服务提供商之一发生了 40 分钟的服务中断……这可能与什么有关吗?也许消防队临时将韩国列入黑名单进行维修?任何帮助将不胜感激...
【问题讨论】:
-
首先,停止忽略错误。在 else 部分添加
Log.d(TAG, task.getException().getMessage());。您是否在 logcat 中打印了一些内容? -
@AlexMamo 这是错误:“com.google.firebase.firestore.FirebaseFirestoreException: 无法获取文档,因为客户端离线。”
-
所以很可能您的互联网连接不正常,对吧?
-
@AlexMamo 就是这样。互联网速度很好,这影响了所有使用 LTE 的用户,而不仅仅是我。因此,互联网连接不是问题。
标签: android firebase google-cloud-firestore