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

Received illegal masked frame, using AS3WebSocket library #21

Closed
mantolo opened this issue Apr 18, 2012 · 16 comments
Closed

Received illegal masked frame, using AS3WebSocket library #21

mantolo opened this issue Apr 18, 2012 · 16 comments

Comments

@mantolo
Copy link

mantolo commented Apr 18, 2012

hi,
I am now using AS3Websocket ( https://github.com/Worlize/AS3WebSocket ) to write an AIR web-socket client application, and using application written in C# with Alchemy as server.

when I connect client to websocket.org echo test server( http://www.websocket.org/echo.html ), I can send and receive data perfectly;
when client connect to my server, client sends and server receives; but when server sends and client receives, the client shows error code 1002, said received illegal masked frame from server.

Having a quick look about the error code according to the specification of RFC6455 (http://tools.ietf.org/html/rfc6455#section-5.1)
"A server MUST NOT mask any frames that it sends to the client.".
Hence, I guess there is something wrong about the protocol between the client and server.

I would kindly ask for your support on this issue, any help would be great :)

@ajacksified
Copy link
Member

Thanks- I'll check this out and see what I can confirm.

@ajacksified
Copy link
Member

Confirmed that it's masking when it shouldn't; our implementation of client and server are coupled, so we'll have to do some refactoring to get this working. We're on it, though!

@jrperina
Copy link

+1 seems to be showing up with the latest version of Chrome (version 19).

@mantolo
Copy link
Author

mantolo commented May 17, 2012

Thanks for the reply. It is good to hear that you're getting to fix this issue,
looking forward to see new batch soon!

@0xStuart
Copy link

+1 here. If anyone knows of a quick fix, please contact me. All of a sudden I'm getting bombarded with Chrome folk with this problem. :(

@ajacksified
Copy link
Member

@stuorguk you could try to use https://github.com/gimite/web-socket-js and set window.WEB_SOCKET_FORCE_FLASH = true; I'll be trying to fix this particular issue tonight

@0xStuart
Copy link

Thanks. I dont actually use the client code. Just the server side. I'm just trying to get my head around the masking to see if it's something I can disable quickly.

@mantolo
Copy link
Author

mantolo commented May 18, 2012

Actually I have drilled-down abit to see what was happening in my case.
By comparing data being sent & received, I have found that the message dispatched from server side does not contain header bytes, which should be presented in web-socket frames to describe what data it is.
So if you are looking for a quick fix, you could try to manually create and attach header bytes in your code before you send message.

refer to http://tools.ietf.org/html/rfc6455#section-5.2 for header bytes structure

@0xStuart
Copy link

My code has been hacked about quite a bit, but the header bytes are there from my server. Removing the masking is actually easy. Remove the mask bit, and comment out the mask method call. Seem to have a problem with UTF-8 decoding now... investigating.

@0xStuart
Copy link

Mine is working now. As above, I just commented out the masking code where it builds a packet. I forgot to take out the mask key from the header which caused UTF-8 errors.

@jrperina
Copy link

Stuorguk, can you be a little more specific about what you did? I started commenting out the masking code as well, but now I'm getting unexpected characters encountered issues.

@jrperina
Copy link

I got mine working now too. Just a couple specifics:

In the Hybi10 implementation I commented out the following lines:

In DataFrame.AsFrame():

Mask(); //Uses _header, must call ToBytes before calling Mask

In FrameHeader.ToBytes():

data[0] = (byte) (data[0] | 0x80); //Tells us that this data is masked

data[0] = (byte) (data[0] | 0x80); //Tells us that this data is masked

data[0] = (byte) (data[0] | 0x80); //Tells us that this data is masked

Mask = random.Next(Int32.MaxValue);
headerBytes.Add(BitConverter.GetBytes(Mask));

I test it with both the Flash Socket and against Chrome 19 and it seems ok now. Haven't tested yet against older versions of Chrome.

@ajacksified
Copy link
Member

Thanks; I can put in an emergency fix for now and work on updating the
client later. It gets tricky in that the WebSocket client uses the same
dataframe class, but it may be as simple as passing in a parameter when
creating the data frame to tell it when to mask. This kills the integration
tests.

Does anyone use the client? Would it be a problem to break it for a day or
two, to get the server running?

On Fri, May 18, 2012 at 11:07 AM, jrperina <
reply@reply.github.com

wrote:

I got mine working now too. Just a couple specifics:

In the Hybi10 implementation I commented out the following lines:

In DataFrame.AsFrame():

Mask(); //Uses _header, must call ToBytes before calling Mask

In FrameHeader.ToBytes():

data[0] = (byte) (data[0] | 0x80); //Tells us that this data is masked

data[0] = (byte) (data[0] | 0x80); //Tells us that this data is masked

data[0] = (byte) (data[0] | 0x80); //Tells us that this data is masked

Mask = random.Next(Int32.MaxValue);
headerBytes.Add(BitConverter.GetBytes(Mask));

I test it with both the Flash Socket and against Chrome 19 and it seems ok
now. Haven't tested yet against older versions of Chrome.


Reply to this email directly or view it on GitHub:

#21 (comment)

@coldwired
Copy link

Hi,

I'm experiencing this issue too. jrperina's quick fix works for Chrome but it doesn't work with Safari or an iOS emulator. Has a patch been released for this issue yet?

Thanks,
Colin.

ajacksified added a commit that referenced this issue May 31, 2012
@ajacksified
Copy link
Member

Appears to work and passes all of my tests; used @jrperina fix.

@ajacksified
Copy link
Member

@coldwired Safari and iOS use an old version of the websocket protocol that we haven't built in support for yet; we'll re-open that now that we've moved past this chrome issue.

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

No branches or pull requests

5 participants