Firefox中不支持WebSocket

编程入门 行业动态 更新时间:2024-10-12 14:25:53
本文介绍了Firefox中不支持WebSocket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在Ubuntu 11.04中运行Firefox 7,我注意到socket.io从web套接字回退到xhr-polling,所以我在Firefox的控制台中输入了 WebSocket ,并得到了 pre $参考错误:WebSocket没有定义

在Google Chrome 14中,我得到了

WebSocket 函数WebSocket(){[native code]}

根据这个,自从Firefox 4以来,WebSockets得到了部分支持,并且自从Firefox 6以来得到了全面支持。

$ b $在Firefox 4/5中,WebSockets支持存在,但是禁用了(通过about:config激活)。在Firefox 6中,Mozilla默认启用了WebSockets,但添加了Moz前缀。另外请注意,Firefox 6使用较新的HyBi协议和W3C API。 Chrome在Chrome 14中增加了HyBi协议,尽管Chrome从未使用过前缀。

该协议已经完成,官方第一个版本预计将在6周内发布(电线格式在几个月内没有明显改变)。这个API也已经相当稳定了好几个月,Chrome 14+和Firefox 6+基本上都有相同的API实现。出于某种原因,Mozilla选择比WebSocket前缀更加谨慎。也许这是谷歌对前缀不稳定的API不够谨慎的反应。除非您对二进制消息支持,特定的错误和关闭条件处理或子协议感兴趣选择,那么自从Chrome几年前推出以来,WebSockets API基本上是相同的。如果你正在实现一个WebSocket服务器,那么你需要知道在过去的两年中发生了重大变化的协议的各种版本。

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 ?

解决方案

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.

更多推荐

Firefox中不支持WebSocket

本文发布于:2023-10-24 21:01:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   Firefox   WebSocket

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!