繁体   English   中英

如何修复 Firestore“无法到达 Cloud Firestore 后端”和 Firestore 未同步的问题?

[英]How to fix Firestore 'Could not reach Cloud Firestore backend' and Firestore not syncing?

偶尔我的 Flutter 应用程序无法连接到 Firestore,并抛出以下错误:

6.4.0 - [Firebase/Firestore][I-FST000001] Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: An internal error has occurred, print and inspect the error details for more information.
 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.

这个错误不是因为缺乏互联网连接,因为其他一切都可以正常连接到 WiFi。 发生这种情况时,我的应用程序根本无法连接,尽管有 WiFi,即使等待更长时间也是如此。

我发现当我清除模拟器缓存并清除所有数据时,或者当我使用 Firebase Auth 退出并重新登录应用程序时,错误消失了,方法来自 FirebaseAuth 'signInWithEmailAndPassword()'。 然后我所有的应用程序都正确地与 Firestore 同步。

此外,在第一个错误之后,每隔 5 秒左右就会不断出现如下消息,直到我的调试控制台充满它们:

[C3.1 96DABBD1-6CC6-4E9A-B011-C5EBC32D0E23 127.0.0.1:64613<->216.58.213.234:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.312s, DNS @0.000s took 0.003s, TCP @0.005s took 0.032s, TLS took 0.100s
    bytes in/out: 4846/1139, packets in/out: 7/9, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C4.1 D7B033A7-E01B-4955-A1D4-F77FD131D1E7 127.0.0.1:64615<->216.58.213.234:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.341s, DNS @0.000s took 0.002s, TCP @0.004s took 0.035s, TLS took 0.136s
    bytes in/out: 5205/1139, packets in/out: 8/9, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C5.1 6C246F61-0CE5-41B2-96A7-5899459A8CDF 127.0.0.1:64617<->172.217.16.74:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.341s, DNS @0.000s took 0.003s, TCP @0.004s took 0.031s, TLS took 0.094s
    bytes in/out: 5039/1139, packets in/out: 5/9, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C6.1 B79FD00C-7B4A-46D4-97D5-A1437FD4065B 127.0.0.1:64619<->172.217.16.74:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.331s, DNS @0.000s took 0.004s, TCP @0.006s took 0.031s, TLS took 0.101s
    bytes in/out: 5088/1139, packets in/out: 6/9, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C7.1 FC9A9A87-24F8-4B67-903D-48C20CF85EDC 127.0.0.1:64623<->172.217.16.74:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.468s, DNS @0.000s took 0.002s, TCP @0.004s took 0.066s, TLS took 0.101s
    bytes in/out: 5246/1139, packets in/out: 6/9, rtt: 0.002s, retransmitted packets: 0, out-of-order packets: 0
    [C8.1 9525CA5F-DD20-4293-89B8-1590FBA8BB3A 127.0.0.1:64627<->172.217.19.74:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.346s, DNS @0.000s took 0.003s, TCP @0.005s took 0.032s, TLS took 0.105s
    bytes in/out: 5203/1093, packets in/out: 7/8, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C9.1 7373F792-2C38-4583-9CD7-488D270B38FF 127.0.0.1:64631<->172.217.19.74:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.311s, DNS @0.000s took 0.002s, TCP @0.004s took 0.031s, TLS took 0.103s
    bytes in/out: 4882/1139, packets in/out: 5/9, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C10.1 A4CA01D7-F8DD-48D6-8F6B-0A7F1B1BE81D 127.0.0.1:64635<->172.217.19.74:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.318s, DNS @0.003s took 0.007s, TCP @0.014s took 0.033s, TLS took 0.109s
    bytes in/out: 5110/1139, packets in/out: 7/9, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C11.1 DA879EBE-02BF-4FD4-A63B-708DCD505ED9 127.0.0.1:64637<->172.217.19.74:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 1.032s, DNS @0.000s took 0.002s, TCP @0.004s took 0.031s, TLS took 0.158s
    bytes in/out: 4803/1139, packets in/out: 5/9, rtt: 0.001s, retransmitted packets: 0, out-of-order packets: 0
    [C12.1 B8C5396A-2168-491E-80C9-3681925B6669 127.0.0.1:64641<->172.217.19.74:443]

发生此错误后,尽管从冷启动应用程序,但我无法与 Firestore 同步,并且所有写入仅在本地发生,并且不会在本地添加来自服务器的新数据。

由于它在注销并重新登录后工作,因此我包含了相关的身份验证代码。 我还没有发现问题,但可能是它有什么问题导致了错误:

此方法在应用程序的每次启动时运行。

void checkLoginstatusAndNavigate() {
    auth.getUser.then(
      (user) {
        if (user != null) {

          Navigator.pushReplacementNamed(context, '/home');
        } else {
          Navigator.pushReplacementNamed(context, '/start');
        }
      },
    ).catchError((error) {
      print(error);
      Navigator.pushReplacementNamed(context, '/start');
    });
  }

在我的应用程序的顶部是一个 StreamProvider,它提供了一个 FirebaseUser 流,也许这也很相关。

另外,我没有使用任何 VPN,并且我的 AntiVirus 已关闭。

我将非常感谢任何形式的见解或帮助,因为这是我上周一直试图修复的错误,但没有任何结果:(。

谢谢!

检查您在 Google Cloud Platform 中的 API 限制,您需要能够访问令牌服务 API,否则 firebase 将无法自动刷新令牌。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM