gpt4 book ai didi

c# - Unity+Firebase-数据库[错误] WebSocket : ws_0 - could not connect

转载 作者:行者123 更新时间:2023-11-30 14:06:06 26 4
gpt4 key购买 nike

我似乎无法找到解决此错误的有效解决方案,更完整:

018-06-01 10:33:09 PM [Error] WebSocket: ws_0 - could not connect System.Net.Sockets.SocketException (0x80004005): No route to host

2018-06-01 10:33:09 PM [Error] WebSocket: ws_0 - WebSocketException during handshake Firebase.Database.Internal.TubeSock.WebSocketException: unknown host: ########.firebaseio.com ---> System.Net.Sockets.SocketException: No route to host

注意,以上错误每秒重复几次,ws_#每次递增1

统一 2018.1.1f1

Firebase-Database:最新的,几天前得到的

一段代码:

void Start() {
FirebaseApp.LogLevel = LogLevel.Verbose;
FirebaseDatabase.DefaultInstance.LogLevel = LogLevel.Verbose; // Or your database instance, if not using the default.

FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available) {
FirebaseApp app = FirebaseApp.DefaultInstance;
// NOTE: You'll need to replace this url with your Firebase App's database
// path in order for the database connection to work correctly in editor.
app.SetEditorDatabaseUrl("https://########.firebaseio.com/");
if (app.Options.DatabaseUrl != null) app.SetEditorDatabaseUrl(app.Options.DatabaseUrl);
} else {
Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
}

下面是我尝试访问firebase数据库

DatabaseReference mDatabaseRef = FirebaseDatabase.DefaultInstance.RootReference;
staticLocalData.thisUser = new UserData();
staticLocalData.thisUser.userID = newUser.UserId;
staticLocalData.thisUser.email = email;
staticLocalData.thisUser.firstName = firstName;
staticLocalData.thisUser.lastName = lastName;
registerData temp = new registerData();
temp.firstName = firstName;
temp.lastName = lastName;
temp.email = email;
temp.userName = userName;

Debug.Log(JsonUtility.ToJson(temp));
mDatabaseRef.Child("users").SetValueAsync("saddsa:23");
//mDatabaseRef.Child("users").Child(newUser.UserId).SetRawJsonValueAsync(JsonUtility.ToJson(temp));

规则集:(应该允许所有)

{
"rules": {
".read": true,
".write": true
}
}

补充说明:

最佳答案

使用:

OSX Sierra 10.12.6 上的 Unity 编辑器 2018.2.5f1

脚本运行时 4.x

脚本后端 IL2CPP

API 级别 4.x

Firebase 插件版本 5.2.1

发生了完全相同的问题。这似乎与 Mono Websocket 实现有关,正如在以下问题上更详细地讨论的那样:

https://github.com/firebase/quickstart-unity/issues/106

https://github.com/firebase/quickstart-unity/issues/162

Firebase 开发团队通过为每个平台提供他们自己的 native websocket 实现来绕过那里描述的内容。显然,Unity Editor 的实现落后了。

此处解决此问题的方法是为编辑器平台禁用 ../Firebase/Plugins/Mono/下的 FirebaseDatabase.dll,然后直接在 ../Firebase/Plugins/下启用一个 FirebaseDatabase.dll .

到目前为止,还不错。

关于c# - Unity+Firebase-数据库[错误] WebSocket : ws_0 - could not connect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50651865/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com