Jamona Mican
Jamona Mican

Reputation: 1654

Websockets anomaly in Chrome 19 (latest beta)

I've been using websockets without an issue for months to communicate between Chrome and my localhost app. Suddenly, with the latest version of Chrome, data is not going through cleanly.

In the Chrome extension's javascript, the relevant part of the code is:

window.ws = new WebSocket("ws://localhost:13000/");

window.ws.onopen = function () {
    window.ws.send('GO');

In my C# app:

string msg = ASCIIEncoding.UTF8.GetString(buffer);
Debug.WriteLine(msg);

For months this worked fine and I would get "GO" back out day in, day out. Now what I'm getting on the receiving buffer is 4 bytes {114,247,7,0) which does not translate to "GO" in any encoding I can find. Anyone have any idea what could be happening? I'm bemused as I have not touched either end of code (chrome or listener).

Cheers!

PS: The full Chrome Version 19.0.1084.15 beta-m

Upvotes: 1

Views: 1862

Answers (2)

moka
moka

Reputation: 23053

Read some data regarding Masking. Browser may send messages with Masking enabled, and it will add extra 4 bytes into frame that will apply masking to your messages. Browsers may have it enabled or disabled, so on server side you should support both and use masking if frame contains masking enabled bit.

Check out how masking is applied based on RFC 6455

Upvotes: 0

Jamona Mican
Jamona Mican

Reputation: 1654

Figured it out. Turns out Chrome has just enabled compression on websockets by default. I just needed to modify the websocket server on my end to refuse that extension and Chrome reverts to plain text.

Upvotes: 2

Related Questions