【发布时间】:2022-01-23 12:10:49
【问题描述】:
我正在开发使用 Google Cloud Firestore 作为数据库的 .NET Windows 窗体应用程序。我创建了函数(使用 Google.Cloud.Firestore NuGet Package 函数)来读取/写入数据库文档。一切正常,但如果应用程序不使用任何读/写功能超过 2-3 分钟,我会收到此错误:Grpc.Core.RpcException: 'Status(StatusCode="Unknown", Detail="Stream removed" 但如果每 1-2 分钟使用读/写功能,我不会在短时间内得到这个错误。我可以创建一个线程函数来保持我的数据库连接处于活动状态,但这会导致不必要的读取或写入。我该如何解决?
重现错误
string Path = AppDomain.CurrentDomain.BaseDirectory + @"AdminSDKName.json";
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Path);
FirestoreDb DataBase = FirestoreDb.Create("DatabaseID");
Query QRef = DataBase.Collection("CollectionID").Document("DocID").Collection("CollectionID").WhereEqualTo("isTrue", false);
QuerySnapshot snap = await QRef.GetSnapshotAsync();
Console.WriteLine(snap.Count.ToString());
Console.WriteLine("Waiting for 5 minutes..");
Task.Delay(300000).Wait();
Console.WriteLine("Waited for 5 minutes");
snap = await QRef.GetSnapshotAsync();
Console.WriteLine(snap.Count.ToString());
Console.WriteLine("Done without any error.");
“等待 5 分钟”行后出现错误。
更新
如果我将计算机网络连接到手机网络,则不会出现任何错误。
【问题讨论】:
-
这个Github issue link 解释说问题出在使用默认开发证书启用的 GRPC 服务器上,如果有帮助,请告诉我。
-
@ZeenathSN 我没有使用 API.NET,他提到“需要 SSL”。有没有办法可以更改 FirestoreDB 客户端设置?
标签: google-cloud-firestore google-api-dotnet-client