Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HyBi-07 spec support #12

Closed
wants to merge 6 commits into from
Closed

Add HyBi-07 spec support #12

wants to merge 6 commits into from

Conversation

alecgorge
Copy link

This changes make this project conform to this draft of the specs: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07

There are no backward compatibility breaks in the server or client. The new server code is only active if the Sec-WebSocket-Version header is equal to 7.

Another item was added to the enum as VERSION_07. This is only used on the client as draft detection is easier on the server than the difference between draft 75 and 76.

I wish to add this feature because the only working iOS WebSocket client only support this draft revision.

@TooTallNate
Copy link
Owner

Wow! Looking good! Do you know if there's any (beta) builds of any web browser that can work with this?

@TooTallNate
Copy link
Owner

And one more thing, I consider the Server accepting an optional DRAFT a feature. If/when a new version comes out, and a user of this lib doesn't want to accept version 7 clients anymore (for security reasons or whatever), that's when it would be needed. So if you could add an "if" check around your new version 7 server logic, it would be appreciated! Thanks for this!

@alecgorge
Copy link
Author

Early Firefox builds have it: http://www.ducksong.com/misc/websockets-builds/ws-07/5.0.a2.03/

Yeah, no problem, I am just a bit confused about what you want me to do. Do you want me to have an if(this.draft != WebSocketDraft.AUTO) block around the version 7 block?

@TooTallNate
Copy link
Owner

it should happen if auto was passed or if version 7 was explicitly passed:

if (this.draft == WebSocketDraft.AUTO || this.draft == WebSocketDraft.VERSION_7)

Sent from my iPhone

On May 7, 2011, at 11:41, alecgorgereply@reply.github.com wrote:

Early Firefox builds have it: http://www.ducksong.com/misc/websockets-builds/ws-07/5.0.a2.03/

Yeah, no problem, I am just a bit confused about what you want me to do. Do you want me to have an if(this.draft != WebSocketDraft.AUTO) block around the version 7 block?

Reply to this email directly or view it on GitHub:
#12 (comment)


String websocketVersion = p.getProperty("Sec-WebSocket-Version");

if (this.draft == WebSocketDraft.AUTO || this.draft == WebSocketDraft.VERSION_7) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebSocketDraft.VERSION_7 -> WebSocketDraft.VERSION_07

@TooTallNate
Copy link
Owner

Hhmmmm.... so I can't seem to get this work with the ChatClient (using the new VERSION_07) and the ChatServer (using, well, any draft version). The onOpen event never fires...

@alecgorge
Copy link
Author

Hmm. I'll look at it this evening. I don't know why it isn't working now.

@TooTallNate
Copy link
Owner

Cool thanks, I'm excited to get this merged!

On Tue, May 10, 2011 at 9:18 AM, alecgorge <
reply@reply.github.com>wrote:

Hmm. I'll look at it this evening. I don't know why it isn't working now.

Reply to this email directly or view it on GitHub:
#12 (comment)

@alecgorge
Copy link
Author

I just tried and it worked for me. Maybe start with a clean directory?

@TooTallNate
Copy link
Owner

I don't think you're updating the ChatClient example to use the new draft version. Try after doing this:

diff --git a/example/ChatClient.java b/example/ChatClient.java
index d72613e..f03294f 100644
--- a/example/ChatClient.java
+++ b/example/ChatClient.java
@@ -117,7 +117,7 @@ public class ChatClient extends WebSocketClient {
                 connect.setEnabled(false);
                 uriField.setEditable(false);
                 try {
-                    cc = new ChatClient(new URI(uriField.getText()), area, WebSocketDraft.DRAFT76);
+                    cc = new ChatClient(new URI(uriField.getText()), area, WebSocketDraft.VERSION_07);
                     cc.connect();
                 } catch (URISyntaxException ex) {
                     area.append(uriField.getText() + " is not a valid WebSocket URI\n");

FWIW, before applying the above patch things are still working properly, since the ChatClient is attempting to connect to the server with DRAFT76, so it appears as though something isn't quite right with the new code.

@alecgorge
Copy link
Author

Ah, I see what you mean now.

That is odd. This one looks like it might be tricky to find.

@TooTallNate
Copy link
Owner

I can try to help diagnose, but do you know of an article anywhere or something that breaks down the differences from this new draft version from the previous one? Or if the differences are few, just list them off for me? I'm kind of clueless as to what this new version includes/fixes and whatnot. Thanks!

@alecgorge
Copy link
Author

I just read the spec ( I think there is a link in the op) and the Wikipedia article on websockets (it has an example).

Sent from my iPhone

On May 11, 2011, at 12:03 PM, TooTallNatereply@reply.github.com wrote:

I can try to help diagnose, but do you know of an article anywhere or something that breaks down the differences from this new draft version from the previous one? Or if the differences are few, just list them off for me? I'm kind of clueless as to what this new version includes/fixes and whatnot. Thanks!

Reply to this email directly or view it on GitHub:
#12 (comment)

@TooTallNate
Copy link
Owner

So I just tried the Nightly firefox build that you linked to above. It doesn't seem to be connecting with the new draft, it still seems like draft 76 to me. Here's a dump of the Firefox build linked above, with a WebSocket connection attempt:

GET / HTTP/1.1
Connection: Upgrade
Origin: file://
Sec-WebSocket-Key2: 1$  8"9 *i  95  T   6314\0
Host: localhost:5555
Upgrade: WebSocket
Sec-WebSocket-Key1: 19 4"84     7 4   080

?c??6ƈ

So it seems as though I can't test your code with that Firefox build. Does connecting to the server work properly from the iOS lib you linked to in the OP?

@ryangraham
Copy link

Nightly tries to auto-update itself away from McManus's hybi-07 build and then you get stuck with draft 76 again. I like to go up a few directories on ducksong and install the latest version immediately before testing.

@TooTallNate
Copy link
Owner

Ended up merging #40 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants