我使用Firebase实时数据库保存我的游戏数据。当没有互联网并且我尝试发送JSON数据时,经常会出现内部错误。似乎它一直在尝试发送数据,但是我只调用了一次。这会导致控制台内部出现错误日志垃圾。
FirebaseDatabase.DefaultInstance.RootReference
.Child("users")
.Child(GetUserID())
.SetRawJsonValueAsync(json)
.ContinueWith(task => {
if (task.Exception != null || task.IsCanceled || task.IsFaulted) {
Debug.LogError("FirebaseStorageService - Upload User Data - FAILED!");
} else {
Debug.Log("FirebaseStorageService - Upload User Data - DONE");
}
});
我希望进入传递给ContinueWith的回调方法,并能够在那里处理异常。似乎我应该拥有的“ task.Exception”。我也不能去那个街区。
我反复收到的错误消息:
09-13 11:50:51.777 30555 31681 E Unity : 09/13/2018 08:50:51 [Error] WebSocket: ws_5 - WebSocketException during handshake
09-13 11:50:51.777 30555 31681 E Unity : Firebase.Database.Internal.TubeSock.WebSocketException: unknown host: cooking-game-88ssd.firebaseio.com ---> System.Net.Sockets.SocketException: No such host is known
09-13 11:50:51.777 30555 31681 E Unity : at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in <filename unknown>:0
09-13 11:50:51.777 30555 31681 E Unity : at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
09-13 11:50:51.777 30555 31681 E Unity : at Firebase.Database.Internal.TubeSock.WebSocket.GetIpAddress (System.String hostName) [0x00000] in <filename unknown>:0
09-13 11:50:51.777 30555 31681 E Unity : --- End of inner exception stack trace ---
09-13 11:50:51.777 30555 31681 E Unity : at Firebase.Database.Internal.TubeSock.WebSocket.CreateSocket () [0x00000] in <filename unknown>:0
09-13 11:50:51.777 30555 31681 E Unity : at Firebase.Database.Internal.TubeSock.WebSocket.RunReader () [0x00000] in <filename unknown>:0
更新1: 我刚刚发现,这不只是发送或检索。即使有以下声明,我仍然收到了这些消息:
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
更新2:
Firebase 4.2版