Firebase - 在建立连接之前关闭 WebSocket。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12421993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Firebase - WebSocket is closed before the connection is established.
提问by markbarton
Just starting out with Firebase (great concept BTW) and I notice in the Chrome console it reports "WebSocket is closed before the connection is established"
刚开始使用 Firebase(顺便说一句,很棒的概念),我注意到在 Chrome 控制台中它报告“在建立连接之前 WebSocket 已关闭”
It still works but wondered why that might be happening - is it anything to be concerned about?
它仍然有效,但想知道为什么会发生这种情况 - 有什么需要担心的吗?
Interestingly it does state there is a successful websocket connection.
有趣的是,它确实声明有一个成功的 websocket 连接。
Thanks
谢谢
采纳答案by Andrew Lee
This is a known issue. The Firebase client attempts to establish a real-time connection to the Firebase servers using multiple methods. If one of those methods succeeds before the Websocket does, we cancel the Websocket and you see that warning. You can safely ignore the error.
这是一个已知的问题。Firebase 客户端尝试使用多种方法与 Firebase 服务器建立实时连接。如果其中一种方法在 Websocket 之前成功,我们将取消 Websocket,您会看到该警告。您可以放心地忽略该错误。
回答by benjarwar
I've been troubleshooting this issue for weeks, and can reproduce it consistently. Sometimes I get the WebSocket is closedwarning, other times it's an actual error:
数周以来,我一直在解决此问题,并且可以始终如一地重现它。有时我收到WebSocket is closed警告,有时是实际错误:
WebSocket connection to 'wss://s-usc1c-nss-214.firebaseio.com/.ws?v=5&ns=foo' failed: WebSocket opening handshake timed out
WebSocket 连接到“wss://s-usc1c-nss-214.firebaseio.com/.ws?v=5&ns=foo”失败:WebSocket 打开握手超时
Had a long email chain with support. They stated "it shouldn't be that long to establish connection the way your app did" and that "it seems that this is outside the Google network, and without any further data, this is just probably just regular internet connectivity mayhem."
有一个很长的电子邮件链支持。他们表示“按照您的应用程序的方式建立连接不应该那么长”,并且“似乎这在 Google 网络之外,并且没有任何进一步的数据,这可能只是常规的互联网连接混乱。”
But I agree with @Xi Xiao above, that "freezing for 30secs is not an eligible solution." I've created a GitHub Issuedetailing the problem and suggesting a couple solutions.
但我同意上面的@Xi Xiao,“冻结 30 秒不是合格的解决方案”。我创建了一个 GitHub 问题,详细说明了问题并提出了几个解决方案。
回答by cbrwizard
This caused flakiness in my Cypress e2e tests.
As a temporary solution, I had to set defaultCommandTimeoutto 35000in Cypress config as specified in Cypress docs.
这在我的 Cypress e2e 测试中造成了片状。作为临时解决方案,我必须在Cypress docs 中指定的 Cypress 配置中设置defaultCommandTimeout为。35000

