4

I came across this code change in Chromium. It says Chromium now supports both handshake versions, which the code seems to confirm. I mean the second version at Wikipedia (draft-ietf-hybi-thewebsocketprotocol-06).

However, when I connect to my server, the only thing I obtain is the old version, i.e. including these headers:

Sec-WebSocket-Key1: 4 @1  46546xW%0l 1 5
Sec-WebSocket-Key2: 12998 5 Y3 1  .P00

but not the new version which would be a request containing:

Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==

What am I missing here? I downloaded the latest nightly build and it has been included more than two weeks ago, so that cannot be the cause I guess.

How can I make a WebSocket send the new handshake version?

pimvdb
  • 151,816
  • 78
  • 307
  • 352
  • Update: Current Chrome stable sends the new handshake format, so this question doesn't apply anymore. One can use the new format in Chrome with no problems now. – pimvdb Nov 23 '11 at 16:22

2 Answers2

4

The code link you posted is for the server-side of the handshake (there is a few places this will likely be used in Chrome such as remote debugging and as a proxy for extensions).

If you really want use the new HyBi-07 protocol version you can try using this branch of web-socket-js that I made. Once Chrome switch to the new protocol, web-socket-js will switch by default also. In order to make web-socket-js work in a browser that already has WebSockets support you will need make some minor tweaks to it to use a different object name instead of WebSocket.

I expect Chrome/WebKit will add the new protocol before long. Note that the API changes to add binary support have only recent been decided so Chrome the new protocol may be added before the API fully supports the new functionality enabled by the protocol.

kanaka
  • 70,845
  • 23
  • 144
  • 140
  • I did not know it was such an actual topic. Thanks for your explanation and links. However, could you possibly tell me what use web-socket-js has over the native WebSocket interface of Chrome? I'm sorry but I could not really tell the difference. – pimvdb May 31 '11 at 20:14
  • pimvdb: The new version of the protocol addresses some security concerns with misbehaving HTTP proxies and it also adds binary message support. You were asking how to use the new protocol and since I'm not aware of any browsers which currently have the new protocol released, you could use the web-socket-js shim to get the new protocol (although that branch of web-socket-js does not implement the binary support yet). If you don't have a specific need for the new protocol than just use the old protocol that is built into current Chrome versions. – kanaka Jun 02 '11 at 16:06
1

The only browser I know of that implements the 07 protocol is this build of FF4:

http://www.ducksong.com/misc/websockets-builds/ws-07/

Stick
  • 11
  • 1