无法从React Native连接到firebase。我可以看到它一直在重试,但从未成功。有没有人成功连接到React原生的firebase?这是在iOS 9模拟器上。
Firebase调试日志:
2015-10-22 12:58:31.018 [info][tid:com.facebook.React.JavaScript] 'p:0: Browser went online. '
2015-10-22 12:58:31.025 [info][tid:com.facebook.React.JavaScript] 'p:0: Listen called for /appversions default '
2015-10-22 12:58:31.026 [info][tid:com.facebook.React.JavaScript] 'p:0: Listen called for /systemstatus/message default '
2015-10-22 12:58:31.032 [info][tid:com.facebook.React.JavaScript] 'p:0: Making a connection attempt '
2015-10-22 12:58:31.033 [info][tid:com.facebook.React.JavaScript] 'c:0:0: Connection created '
2015-10-22 12:58:31.036 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5 '
2015-10-22 12:58:31.038 [info][tid:com.facebook.React.RCTWebSocketManagerQueue][RCTSRWebSocket.m:520] SocketRocket: In debug mode. Allowing connection to any root cert2015-10-22 12:58:31.815 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 Websocket connected. '
2015-10-22 12:58:31.816 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 Websocket connection was disconnected. '
2015-10-22 12:58:31.816 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 WebSocket is closing itself '
2015-10-22 12:58:31.817 [info][tid:com.facebook.React.JavaScript] 'c:0:0: Closing realtime connection. '
2015-10-22 12:58:31.817 [info][tid:com.facebook.React.JavaScript] 'c:0:0: Shutting down all connections '
2015-10-22 12:58:31.817 [info][tid:com.facebook.React.JavaScript] 'p:0: data client disconnected '
2015-10-22 12:58:31.818 [info][tid:com.facebook.React.JavaScript] 'p:0: Trying to reconnect in 112.12895049713552ms '
2015-10-22 12:58:31.819 [info][tid:com.facebook.React.JavaScript] '0: onDisconnectEvents '
2015-10-22 12:58:31.932 [info][tid:com.facebook.React.JavaScript] 'p:0: Making a connection attempt '
2015-10-22 12:58:31.933 [info][tid:com.facebook.React.JavaScript] 'c:0:1: Connection created '
2015-10-22 12:58:31.934 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5 '
2015-10-22 12:58:31.934 [info][tid:com.facebook.React.RCTWebSocketManagerQueue][RCTSRWebSocket.m:520] SocketRocket: In debug mode. Allowing connection to any root cert
2015-10-22 12:58:32.698 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 Websocket connected. '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 Websocket connection was disconnected. '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 WebSocket is closing itself '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1: Closing realtime connection. '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1: Shutting down all connections '
2015-10-22 12:58:32.700 [info][tid:com.facebook.React.JavaScript] 'p:0: data client disconnected '
2015-10-22 12:58:32.700 [info][tid:com.facebook.React.JavaScript] 'p:0: Trying to reconnect in 28.659726264886558ms '
2015-10-22 12:58:32.701 [info][tid:com.facebook.React.JavaScript] '0: onDisconnectEvents '
2015-10-22 12:58:32.732 [info][tid:com.facebook.React.JavaScript] 'p:0: Making a connection attempt '
2015-10-22 12:58:32.732 [info][tid:com.facebook.React.JavaScript] 'c:0:2: Connection created '
2015-10-22 12:58:32.733 [info][tid:com.facebook.React.JavaScript] 'c:0:2:0 Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5 '
2015-10-22 12:58:32.733 [info][tid:com.facebook.React.RCTWebSocketManagerQueue][RCTSRWebSocket.m:520] SocketRocket: In debug mode. Allowing connection to any root cert
答案 0 :(得分:0)
只是在日志中的一个想法:
Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5
也许您需要配置firebase应用程序名称,或者它是否显示无论如何?
答案 1 :(得分:0)
这是由于反应原生的WebSocket polyfill的一个错误,应该在最新的位(https://github.com/facebook/react-native/commit/607527c0d4bf6d8197829f3523c4d937ac71ed07)中修复。请尝试更新并查看问题是否消失!
答案 2 :(得分:0)
还要确保您已在Firebase数据库上启用了公开读取权限。 Firebase Db setup