如何修复Firestore'无法到达Cloud Firestore后端'并且Firestore无法同步?

问题描述 投票:0回答:1

偶尔我的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');
    });
  }

我的应用程序顶部是提供FirebaseUser流的StreamProvider,也许这也很重要。

此外,我没有使用任何VPN,并且我的防病毒软件已关闭。

我将非常感谢您提供的任何见解或帮助,因为这是我在上个星期一直试图解决的错误,但没有任何结果:(。

谢谢!

android firebase flutter google-cloud-firestore firebase-authentication
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.