Firefox中不支持WebSocket [英] Are WebSockets not supported in Firefox

查看:1228
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆