gimite / web-socket-js

HTML5 Web Socket implementation powered by Flash
BSD 3-Clause "New" or "Revised" License
2.73k stars 489 forks source link

HyBi-07 protocol support and WebSocket.protocol fix #70

Closed kanaka closed 13 years ago

kanaka commented 13 years ago

gimite,

The HyBi-07 version of the protocol is now in last-call so I've decided to implement support for it in web-socket-js. Firefox has a test build with support for 07 here: http://www.ducksong.com/misc/websockets-builds/ws-07/5.0.a2.01/

4 of these commits are to implement HyBi-07. To avoid clutter I didn't maintain support for hixie-76 in the code-base. I'm open to adding back 76 with a configuration flag to select between them. Let me know if you want me to do that before you pull. However, since native WebSockets support probably won't have a flag, it might be better to generate two separate builds (one for Hixie-76 and one for HyBi-07) so that the developer can choose which one to use depending on what their server supports.

I've also added HyBi-07 support to https://github.com/kanaka/websockify.

The other commit is regarding the protocol parameter and attribute. web-socket-js should now more closely match the spec. It accepts a list of protocols in the open parameter (instead of just 1) and will report the one chosen by the server in the protocol object attribute.

imanel commented 13 years ago

I think that it's not very good moment to pull this request to master. Currently "standard" for server side is draft 76/00 and other drafts are technically "dead"(nearly no server support, absolutely no client support) Until most servers will be able to handle draft 07 there is no reason to move to that draft - this would actually make this script unusable. On the other hand it's good that we have working(?) implementation of draft 07 - it's good base to implement later drafts in future. At this point WebSockets is starting to stabilize and it's probably good point to make some base for future implementation of final version of protocol. Thus it may be good idea to pull this to separate branch and just leave there open for next pull requests with bugfixes/implementations of next drafts. This could have 2 profits - one is easy way to move to final protocol in future, and other is that we could tag protocol drafts from time to time allowing server developers to have testing tool(currently there is no way to test draft 01-07 except of tests builds of firefox)

kanaka commented 13 years ago

@imanel. I wasn't suggesting that it be pulled as is which is why I suggested a couple of options. Either the code can generate two swf files so the developer can choose based on the server they are trying to connect to. Or there can be a configuration option to select which protocol to use. I'm willing to work on either but I posted the patch in pure form for comment (having the older protocol mixed in would make it more difficult to review.

The only browser right now with support for HyBi-07 is a special build of firefox. However, describing it as "dead" is inaccurate. All the browser vendors are working on implementing HyBi-07. Even Microsoft is working on it and participating actively in the discussion. In fact, 07 just went into IETF working group last-call state which is generally a 2 week period before it moves to IESG evaluation (which is kind of the opposite of the IETF working group "dead" state).

Also, many of the server libraries have already implemented 07 support (due to last-call) including:

There are some non-core issues still being discussed (compression, muxing), but it's likely that 07 will be published as is. Even if it isn't published until 08, it's still unlikely that the core of the 07 protocol will be changed. So now is exactly the right time for browser vendors (and other WebSockets clients) to begin implementing so that they can give feedback during the last-call.

In fact, the biggest area that is likely to change is not in the protocol itself, but rather related to discussion around changes to the API to support the new binary payload support added to the protocol: http://www.w3.org/Bugs/Public/show_bug.cgi?id=12102

gimite commented 13 years ago

Good job, thanks for doing this. I'd like to pull this to main branch when Chrome switch to new protocol. At that point, servers need to support new protocol anyway. So I believe it's good timing. Until then, I'll create another branch to pull this change.

Once we switch to new version, I don't think we need to support both versions. Web Socket protocol is still in early stage, so I believe old version such as 75, 76 will die soon after new version is started to use. I'll leave old branch for a while, though.

I cherry-picked 20c16e6 to main branch.

kanaka commented 13 years ago

gimite, I agree with the timing. Chrome will probably be first. Once Chrome switches, most servers will update soon after (if they haven't done so already). And keeping both branches around for a while will allow developers to use the old version if they want to.

gimite commented 13 years ago

Thanks. Pulled to hybi-07 branch. https://github.com/gimite/web-socket-js/tree/hybi-07