Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the protocol differences between WebSockets versions?

Is there a summary anywhere of the protocol difference between the various WebSockets drafts?

The browser support levels are still all over the place, so it is not sufficient just to consider the RFC.

Obviously the Sec-WebSocket-Version changes, and I know the early format was pretty radically different. However, I mean the more subtle changes in the protocol. For example, hybi-10 (v8), in framing, suggests the extended payload length is stored as 16/63, rather than 16/64 in RFC 6455 (v13).

So: is there a summary of changes anywhere?

Alternatively (if we ignore the very early drafts, and the version numbers), is it the case that the protocol is essentially the same, and that the drafts are mainly corrections to the specification text?

like image 707
Marc Gravell Avatar asked Feb 11 '12 10:02

Marc Gravell


People also ask

What protocols do WebSockets use?

The WebSocket protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request. By default the WebSocket protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over TLS [RFC2818].

What is the difference between WSS and WS?

The wss protocol establishes a WebSocket over an encrypted TLS connection, while the ws protocol uses an unencrypted connection. At this point, the network connection remains open and can be used to send WebSocket messages in either direction.

What are some differences between WebSockets and HTTP?

Unlike HTTP, where you have to constantly request updates, with websockets, updates are sent immediately when they are available. WebSockets keeps a single, persistent connection open while eliminating latency problems that arise with HTTP request/response-based methods.

What is WSS instead of https?

wss is secure only because it means "WebSocket protocol over https". WebSocket protocol itself is not secure. There is no Secure WebSocket protocol, but there are just "WebSocket protocol over http" and "WebSocket protocol over https". See also this answer.


2 Answers

The Wikipedia WebSocket lists which browsers support which protocol.

Also, the IETF provides an diff tool that can be used to compare any two RFC draft specifications. For example, to compare WebSocket draft 15 and 17 go here:

  • http://tools.ietf.org/rfcdiff?url1=draft-ietf-hybi-thewebsocketprotocol-15.txt&url2=draft-ietf-hybi-thewebsocketprotocol-17.txt

Adjust the url1 and url2 addresses to get a diff for arbitrary versions. Note that this will shows you textual differences to the spec and large changes to the spec often happen without corresponding differences on the wire. I suggest searching the diffs for the "Protocol Overview" section and the "Base Framing Protocol" section which show the header summary and the framing diagram respectively.

The biggest difference in the wire protocol occured between Hixie-76/HyBi-00 (HyBi-00 was just a copy of Hixie-76 for starting the new series) and the rest of the HyBi series starting with HyBi-04 (HyBi-17 became IETF RFC 6455). Some of the major changes from the Hixie series to the HyBi series:

  • In the Hixie-76 protocol, there was a peculiar hash handshake that happened after the handshake headers but before the actual data frames.
  • In Hixie-76, the frames were prefixed with 0x00 and suffixed with 0xff. There was no way to determine the length of the frame except by receiving/buffering all the way to the end of the frame. In the HyBi series (after HyBi-00) the frame length is part of the prefix/header and there is no suffix.
  • The HyBi series supports both UTF-8 text and binary data in the payload (Hixie only supported UTF-8). This is indicated by and opcode in the frame header.
like image 167
kanaka Avatar answered Sep 19 '22 11:09

kanaka


To add a specific change; in Sec-WebSocketVersion <= 8, the origin is in Sec-WebSocket-Origin; however, in 13 this changes to the Origin header. This changes specifically between hybi-10 and hybi-11, which are both version "8" implementations. Also note that it is Origin in hixie-76/hybi-00, so it looks like it went from Origin to Sec-WebSocket-Origin and then back to Origin.

like image 26
Marc Gravell Avatar answered Sep 22 '22 11:09

Marc Gravell