MDN wants to learn about developers like you:


WebSockets 是一个可以创建和服务器间进行双向会话的高级技术。通过这个API你可以向服务器发送消息并接受基于事件驱动的响应,这样就不用向服务器轮询获取数据了。


用于连接WebSocket服务器的主要接口,之后可以在这个连接上发送 和接受数据。


  • HumbleNet: A cross-platform networking library that works in the browser. It consists of a C wrapper around WebSockets and WebRTC that abstracts away cross-browser differences, facilitating the creation of multi-user networking functionality for games and other apps.
  • µWebSockets: Highly scalable WebSocket server and client implementation for C++11 and Node.js.
  • Socket.IO: A long polling/WebSocket based third party transfer protocol for Node.js.
  • SocketCluster: A pub/sub WebSocket framework for Node.js with a focus on scalability.
  • WebSocket-Node: A WebSocket server API implementation for Node.js.
  • Total.js: Web application framework for Node.js (Example: WebSocket chat)
  • Faye: A WebSocket (two-ways connections) and EventSource (one-way connections) for Node.js Server and Client.
  • SignalR: SignalR will use WebSockets under the covers when it's available, and gracefully fallback to other techniques and technologies when it isn't, while your application code stays the same.
  • Caddy: A web server capable of proxying arbitrary commands (stdin/stdout) as a websocket.
  • ws: a popular WebSocket client & server library for Node.js.
  • jsonrpc-bidirectional: Easy to use asynchronous RPC library with bidirectional calls support over a single WebSocket or RTCDataChannel (WebRTC) connection. The TCP/SCTP/etc. client and server may each host its own JSONRPC.Server endpoint at the same time.



We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Version -76 support 6 未实现 4.0 (2.0) 未实现 11.00 (disabled) 5.0.1
Protocol version 7 support 未实现 未实现 6.0 (6.0)
未实现 未实现 未实现
Protocol version 10 support 14 未实现 7.0 (7.0)
HTML5 Labs ? ?
Standard - RFC 6455 Support 16 (Yes) 11.0 (11.0) 10 12.10 6.0
Usable in Workers (Yes) (Yes) 37.0 (37.0) ? ? ?
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Version -76 support ? 未实现 ? ? ? ?
Protocol version 7 support ? 未实现 ? ? ? ?
Protocol version 8 support (IETF draft 10) ? 未实现 7.0 (7.0) ? ? ?
Standard - RFC 6455 Support 4.4 (Yes) 11.0 (11.0) ? 12.10 6.0
Usable in Workers (Yes) (Yes) 37.0 (37.0) ? ? ?

Gecko notes

WebSockets support in Firefox is continuing to track the evolving WebSocket specification. Firefox 6 implements version 7 of the underlying protocol, while Firefox 7 implements version 8 (as specified by IETF draft 10). Firefox mobile received WebSocket support in Firefox mobile 7.0.

Gecko 6.0

Prior to Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3), there was, incorrectly, a WebSocket object that some sites were thinking implied that WebSocket services were not prefixed; this object has been renamed to MozWebSocket.

Gecko 7.0

Starting in Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4), the network.websocket.max-connections preference is used to determine the maximum number of WebSocket connections that can be open at a time. The default value is 200.

Gecko 8.0

Starting in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5), the deflate-stream extension to the WebSocket protocol has been disabled, since it's been deprecated from the specification drafts. This resolves incompatibilities with some sites.

Gecko 11.0

Prior to Gecko 11.0, both incoming and outgoing messages were limited to 16 MB in size. They may now be up to 2 GB in size. Note, however, that memory limitations (especially on mobile devices) make that a theoretical maximum, not a practical one. In reality, transfers of that size will fail on devices that don't have enough memory.


从Gecko 11.0开始 WebSocket API不再使用前缀。


 此页面的贡献者: wodewone, luojia
 最后编辑者: wodewone,