WebSockets

  • Revision slug: WebSockets
  • Revision title: WebSockets
  • Revision id: 819
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 8 words added, 5 words removed

Revision Content

{{ SeeCompatTable() }}

WebSockets is a technology that makes it possible to open an interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.

Documentation

Writing WebSocket client applications
A tutorial guide to writing WebSocket clients to run in the browser.
WebSockets reference
A reference to the client-side WebSocket API.
(TBD) The WebSocket protocol
A reference to the WebSocket protocol.
(TBD) Writing WebSocket servers
A guide to writing server-side code to handle the WebSocket protocol.

View All...

Tools

 

Related Topics

AJAXJavaScript

See also

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Version -76 support {{ obsolete_inline() }} 6 {{ CompatGeckoDesktop("2.0") }} {{ CompatNo() }} 11.00 (disabled) 5.0.1
Protocol version 7 support {{ CompatNo() }} {{ CompatGeckoDesktop("6.0") }}
{{ property_prefix("Moz") }}
{{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Protocol version 10 support 14 {{ CompatGeckoDesktop("7.0") }}
{{ property_prefix("Moz") }}
HTML5 Labs {{ CompatUnknown() }} {{ CompatUnknown() }}
RFC 6455 Support (IETF Draft 17) 16 {{ CompatGeckoDesktop("11.0") }} 10 {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Version -76 support {{ obsolete_inline() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Protocol version 7 support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Protocol version 8 support (IETF draft 10) {{ CompatUnknown() }} {{ CompatGeckoMobile("7.0") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
RFC 6455 Support (IETF Draft 17) 16 {{ CompatGeckoDesktop("11.0") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

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 {{ geckoRelease("6.0") }}, 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 {{ geckoRelease("7.0") }}, 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 {{ geckoRelease("8.0") }}, 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.

Starting in Gecko 11.0, the WebSocket API is no longer prefixed.

Warning: Among other things, a key reason WebSockets was disabled by default in Firefox 4 and 5 is the discovery of a security issue in the protocol's design. Using WebSockets in those versions of Firefox in a production environment is not recommended at this time. If you still wish to experiment with WebSockets, you may do so by opening about:config and setting the network.websocket.enabled preference to true. You will also need to set the network.websocket.override-security-block preference to true in order to allow initializing a WebSocket connection.

{{ HTML5ArticleTOC() }}

{{ languages ( {"es": "es/WebSockets", "zh-tw": "zh_tw/WebSockets"} ) }}

Revision Source

<p>{{ SeeCompatTable() }}</p>
<p>WebSockets is a technology that makes it possible to open an interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.</p>
<table class="topicpage-table"> <tbody> <tr> <td> <h4 name="Documentation"><a href="/Special:Tags?tag=WebSockets&amp;language=en" title="Special:Tags?tag=WebSockets&amp;language=en">Documentation</a></h4> <dl> <dt><a href="/en/WebSockets/Writing_WebSocket_client_applications" title="en/WebSockets/Writing WebSocket client applications">Writing WebSocket client applications</a></dt> <dd>A tutorial guide to writing WebSocket clients to run in the browser.</dd> <dt><a href="/en/WebSockets/WebSockets_reference" title="en/WebSockets/WebSockets reference">WebSockets reference</a></dt> <dd>A reference to the client-side WebSocket API.</dd> <dt><a href="/en/WebSockets/The_WebSocket_protocol" title="en/WebSockets/The WebSocket protocol">(TBD) The WebSocket protocol</a></dt> <dd>A reference to the WebSocket protocol.</dd> <dt><a href="/en/WebSockets/Writing_WebSocket_servers" title="en/WebSockets/Writing WebSocket servers">(TBD) Writing WebSocket servers</a></dt> <dd>A guide to writing server-side code to handle the WebSocket protocol.</dd> </dl> <p><span class="alllinks"><a href="/Special:Tags?tag=WebSockets&amp;language=en" title="Special:Tags?tag=WebSockets&amp;language=en">View All...</a></span></p> </td> <td> <h4 name="Tools">Tools</h4> <ul> <li><a class="external" href="http://socket.io" title="http://socket.io/">Socket.IO</a>: A powerful cross-platform WebSocket API for <a class="external" href="http://nodejs.org" title="http://nodejs.org/">Node.js</a>.</li> <li><a class="link-https" href="https://github.com/Worlize/WebSocket-Node" title="https://github.com/Worlize/WebSocket-Node">WebSocket-Node</a>: A WebSocket server API implementation for <a class="external" href="http://nodejs.org" title="http://nodejs.org/">Node.js</a>.</li> </ul> <p> </p> <h4 name="Related_Topics">Related Topics</h4> <dl> <dd><a href="/en/AJAX" title="en/AJAX">AJAX</a>, <a href="/en/JavaScript" title="en/JavaScript">JavaScript</a></dd> </dl> </td> </tr> </tbody>
</table>
<h2>See also</h2>
<ul> <li><a class=" external" href="http://tools.ietf.org/html/rfc6455">RFC 6455 - The WebSocket Protocol</a></li> <li><a class=" external" href="http://www.w3.org/TR/websockets/">WebSocket API Specification</a></li> <li><a href="/en/Server-sent_events">Server-Sent Events</a></li>
</ul><h2>Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Version -76 support {{ obsolete_inline() }}</td> <td>6</td> <td>{{ CompatGeckoDesktop("2.0") }}</td> <td>{{ CompatNo() }}</td> <td>11.00 (disabled)</td> <td>5.0.1</td> </tr> <tr> <td>Protocol version 7 support</td> <td>{{ CompatNo() }}</td> <td>{{ CompatGeckoDesktop("6.0") }}<br> {{ property_prefix("Moz") }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> </tr> <tr> <td>Protocol version 10 support</td> <td>14</td> <td>{{ CompatGeckoDesktop("7.0") }}<br> {{ property_prefix("Moz") }}</td> <td>HTML5 Labs</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> <tr> <td>RFC 6455 Support (IETF Draft 17)</td> <td>16</td> <td>{{ CompatGeckoDesktop("11.0") }}</td> <td>10</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Version -76 support {{ obsolete_inline() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> <tr> <td>Protocol version 7 support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> <tr> <td>Protocol version 8 support (IETF draft 10)</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatGeckoMobile("7.0") }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> <tr> <td>RFC 6455 Support (IETF Draft 17)</td> <td>16</td> <td>{{ CompatGeckoDesktop("11.0") }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<h3>Gecko notes</h3>
<p>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.</p>
<h4>Gecko 6.0</h4>
<p>Prior to Gecko 6.0 {{ geckoRelease("6.0") }}, there was, incorrectly, a <code>WebSocket</code> object that some sites were thinking implied that <code>WebSocket</code> services were not prefixed; this object has been renamed to <code>MozWebSocket</code>.</p>
<h4>Gecko 7.0</h4>
<p>Starting in Gecko 7.0 {{ geckoRelease("7.0") }}, the <code>network.websocket.max-connections</code> preference is used to determine the maximum number of WebSocket connections that can be open at a time. The default value is 200.</p>
<h4>Gecko 8.0</h4>
<p>Starting in Gecko 8.0 {{ geckoRelease("8.0") }}, 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.</p>
<h4>Gecko 11.0</h4>
<p>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.</p>
<p>Starting in Gecko 11.0, the WebSocket API is no longer prefixed.</p>
<div class="warning"><strong>Warning:</strong> Among other things, a key reason WebSockets was disabled by default in Firefox 4 and 5 is the discovery of a <a class="external" href="http://www.ietf.org/mail-archive/web/hybi/current/msg04744.html" title="http://www.ietf.org/mail-archive/web/hybi/current/msg04744.html">security issue in the protocol's design</a>. Using WebSockets in those versions of Firefox in a production environment is not recommended at this time. If you still wish to experiment with WebSockets, you may do so by opening <code>about:config</code> and setting the <code>network.websocket.enabled</code> preference to <code>true</code>. You will also need to set the <code>network.websocket.override-security-block</code> preference to <code>true</code> in order to allow initializing a WebSocket connection.</div>
<p>{{ HTML5ArticleTOC() }}</p>
<p>{{ languages ( {"es": "es/WebSockets", "zh-tw": "zh_tw/WebSockets"} ) }}</p>
Revert to this revision