Вебсокеты это продвинутая технология, позволяющая открыть постоянное двунаправленное сетевое соединение между браузером пользователя и сервером. С помощью его API вы можете отправить сообщение на сервер и получить ответ без выполнения http запроса, причем этот процесс будет событийно-управляемым.
Документация
- Writing WebSocket client applications
- Учебник описывающий как написать WebSocket клиента работающего в браузере.
- Справочник по WebSocket
- A reference to the client-side WebSocket API.
- (TBD) Writing WebSocket servers
- A guide to writing server-side code to handle the WebSocket protocol.
Tools
- Socket.IO: A powerful cross-platform WebSocket API for Node.js.
- WebSocket-Node: A WebSocket server API implementation for Node.js.
- A more extensive list of frameworks and libraries here
Related Topics
See also
- RFC 6455 - The WebSocket Protocol
- WebSocket API Specification
- Server-Sent Events
- WebSocket.us - a community-run, not-for-profit site about WebSocket
Browser compatibility
Feature | Chrome | 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) Moz |
Нет | Нет | Нет |
Protocol version 10 support | 14 | 7.0 (7.0) Moz |
HTML5 Labs | ? | ? |
Standard - RFC 6455 Support | 16 | 11.0 (11.0) | 10 | 12.10 | 6.0 |
Feature | Android | 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 | 16 (Chrome) | 11.0 (11.0) | ? | 12.10 | 6.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.
Additionally, ArrayBuffer send and receive support for binary data has been implemented.
Starting in Gecko 11.0, the WebSocket API is no longer prefixed.