Firefox 不支持 WebSockets
我在 Ubuntu 11.04 中运行 Firefox 7,我注意到 socket.io 从 Web 套接字回落到 xhr-polling,因此我在 Firefox 的控制台中输入 WebSocket
,并得到了
[00:48:21.224] ReferenceError: WebSocket is not defined
On Google Chrome 14 I get
WebSocket
function WebSocket() { [native code] }
根据 this,WebSockets 从 firefox 4 开始得到部分支持,并从firefox 6.
只是linux上的firefox有所不同吗?
I'm running Firefox 7 in Ubuntu 11.04, and I noticed socket.io was falling back from web sockets to xhr-polling, so I typed WebSocket
in Firefox's console, and got
[00:48:21.224] ReferenceError: WebSocket is not defined
On Google Chrome 14 I got
WebSocket
function WebSocket() { [native code] }
According to this, WebSockets is partly supported since firefox 4 and fully supported since firefox 6.
Is it only different in firefox on linux ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Firefox 4/5 中,WebSockets 支持存在但被禁用(通过 about:config 激活)。在 Firefox 6 中,Mozilla 默认启用 WebSocket,但添加了“Moz”前缀。另请注意,Firefox 6 使用较新的 HyBi 协议和 W3C API。 Chrome 在 Chrome 14 中添加了 HyBi 协议,尽管 Chrome 从未使用过前缀。
该协议已有效完成,正式的第一个版本预计将在大约 6 周内发布(有线格式在几个月内没有发生重大变化)。该 API 几个月来也相当稳定,Chrome 14+ 和 Firefox 6+ 基本上具有相同的 API 实现。出于某种原因,Mozilla 选择对 WebSockets 前缀比平常更加谨慎。也许这是对 Google 对不稳定 API 前缀不够谨慎的反应。
除非您对二进制消息支持、特定错误和关闭条件处理或子协议选择感兴趣,否则自几年前 Chrome 推出以来,WebSockets API 本质上是相同的。如果您正在实现 WebSockets 服务器,那么您将需要了解该协议的各个版本,该协议在过去两年中发生了重大变化。
In Firefox 4/5, WebSockets support is present but disabled (activated via about:config). In Firefox 6, Mozilla enabled WebSockets by default but added the "Moz" prefix. Also, note that Firefox 6 uses the newer HyBi protocol and W3C API. Chrome added the HyBi protocol in Chrome 14 although Chrome has never used a prefix.
The protocol is effectively complete and the official first version is expected to be published in about 6 weeks (the wire format has not changed significantly in months). The API has also been quite stable for months and Chrome 14+ and Firefox 6+ basically have the same implementation of the API. For some reason Mozilla has chosen to be even more cautious than normal with WebSockets prefixing. Perhaps it is a reaction to Google not being careful enough about prefixing unstable APIs.
Unless you are interested in binary message support, specific error and close condition handling or sub-protocol selection, then the WebSockets API has been essentially the same since Chrome introduced it a couple of years ago. If you are implementing a WebSockets server then you will need to know about the various versions of the protocol which has seen significant changes in the past 2 years.
尝试使用
MozWebSocket
来代替。https://developer.mozilla.org/en/WebSockets#AutoCompatibilityTable
Try
MozWebSocket
instead.https://developer.mozilla.org/en/WebSockets#AutoCompatibilityTable
Firefox 7 “直接开箱即用”支持 hybi-10。我一直在我的 Firefox 7 上运行它,支持 hybi-10,“直接开箱即用”。我一直在我的 websocket 服务器上运行它。您可以使用 Firefox 7 尝试我的在线演示,如果有任何问题请告诉我。我已经在 Ubuntu 11 上对其进行了测试。我现在已经进行了设置。
Firefox 7 supports hybi-10 "straight out of the box." I've been running it against my Firefox 7 supports hybi-10 "straight out of the box." I've been running it against my websocket server. You can try my online demo with Firefox 7 and let me know if you have any problem. I've tested it from Ubuntu 11. I have that set up right now.