--- title: WebSockets slug: Web/API/WebSockets_API translation_of: Web/API/WebSockets_API ---

{{DefaultAPISidebar("Websockets API")}}

WebSockets es una tecnología avanzada que hace posible abrir una sesión de comunicación interactiva entre el navegador del usuario y un servidor. Con esta  API, puede enviar mensajes a un servidor y  recibir  respuestas controladas por eventos sin tener que consultar al servidor para una respuesta.

Interfaces

WebSocket
El interfaz principal para conectar a un servidor Websocket y así enviar y recibir datos a través de la conexión.
CloseEvent
El evento enviado por el objeto WebSocket cuando se cierra la conexión.
MessageEvent
El evento enviado por el objeto WebSocket cuando se recibe un mensaje enviado desde el servidor.

Herramientas

Ver también

Compatibilidad con navegadores

{{CompatibilityTable}}

Característica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Versión -76  {{obsolete_inline}} 6 {{CompatGeckoDesktop("2.0")}} {{CompatNo}} 11.00 (disabled) 5.0.1
Protocolo versión 7 {{CompatNo}} {{CompatGeckoDesktop("6.0")}}
{{property_prefix("Moz")}}
{{CompatNo}} {{CompatNo}} {{CompatNo}}
Protocolo versión 10 14 {{CompatGeckoDesktop("7.0")}}
{{property_prefix("Moz")}}
HTML5 Labs {{CompatUnknown}} {{CompatUnknown}}
RFC 6455 (IETF Draft 17) 16 {{CompatGeckoDesktop("11.0")}} 10 12.10 {{CompatUnknown}}
Característica Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Versión -76  {{obsolete_inline}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Protocolo versión 7 {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Protocolo versión 8 (IETF draft 10) {{CompatUnknown}} {{CompatGeckoMobile("7.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
RFC 6455 (IETF Draft 17) 16 {{CompatGeckoDesktop("11.0")}} {{CompatUnknown}} 12.10 {{CompatUnknown}}

Notas para Gecko

La compatibilidad de Firefox con WebSockets ha seguido la evolución de la especificación WebSocket. Firefox 6 implementa la versión 7 del protocolo subyacente, mientras que Firefox 7 implementa la versión 8 (como especifica IETF draft 10). Firefox mobile tuvo compatibilidad con WebSocket en 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.

Additionally, ArrayBuffer send and receive support for binary data has been implemented.

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. This was fixed in Firefox 6 by implementing a newer version of the protocol that corrects the problem.