websocket error in FireFox and Chrome

Dec 20, 2011 at 9:00 PM

I am seeing following error in Chrome:

"Could not decode a text frame as UTF-8."

I am also seeing error in Firefox:

with alert message "error ocuurred [object Event]"

console log: "The connection to ws://10.65.XX.XXX:8090/QuoteWebSocketService was interrupted while the page was loading."

But I am not having any issues when I am using web socket thru Jetty websocket framework in both FireFox and Chrome.

My request are processed using JsonSubCommand and my response are also compose in Json.

Any thoughts what may be causing the problem?



Coordinator
Dec 21, 2011 at 1:50 AM

How do you send response to client?

What's the frequency?

Dec 21, 2011 at 3:40 PM

 

Kerry,

I am using WebSocketSession::SendResponseAsync(String data).

Right now, I am sending aleast 4 to 8 messages every 5 seconds for testing purpose. Whereas my Jetty software is configured to sends more than 20 messages every 150 milliseconds.

I was planning to reduce interval to 150 milliseconds and send atleast 20 messages every 150 milliseconds. 

Please let me know if it is a bottleneck in your software than I can fix it. Or it is issue with sending partial data.

Thanks,

SKB

Coordinator
Dec 21, 2011 at 3:55 PM

It may be a racing issue of multiple thread sending, I'll try to fix it on these days.

Coordinator
Dec 24, 2011 at 2:46 PM

Could you download latest source code from SVN, and then verify whether this issue has been fixed.

Jan 3, 2012 at 11:40 PM

kerry,

   I will try your changes by tomorrow.

 

Thanks,

SKB

Jan 3, 2012 at 11:43 PM

Kerry,

I am planning to send 2000 - 20000 messages per seconds, Will the server handle the load?

Coordinator
Jan 4, 2012 at 12:10 AM

How many connections? 2000 - 20000 messages per connection or in total?

It depend on your hardware. On my laptop, it can handle 20k above messages per second.

Jan 5, 2012 at 3:52 PM

Kerry,

20K+ messages per connection. I understand that it will depend on hardware, other OS restrictions, and app code around it.

I am trying to accomplish around 10,000 connections with 20K messages per connection per seconds. 

I was going to test but supersocket code for ArraySegmentList::DecodeMask (and Decode) is not working. Please address the issue before I can even try it [it should be an easy fix].

Here is the sample code for testing ( result from TextNotWorking should match TextWorking ):

        static public void TestDecodeVerify()       

{           

ArraySegmentList source = new ArraySegmentList();           

byte[] data = new byte[] { 183, 229, 24, 166, 131, 195, 2, 176, 149, 243, 5, 187, 150, 228, 30, 189, 136, 176, 12, 240, 180, 245, 6, 167, 131, 227, 3, 134, 159, 224, 18, 240, 220, 178, 36, 167, 132, 227, 20, 160, 143, 242, 18, 240, 202, 178, 36, 167, 132, 227, 20, 160, 143, 242, 18, 134, 159, 224, 18, 240, 220, 178, 27, 183, 144, 245, 27, 227, 196, 188, 85, 129, 159, 253, 21, 189, 138, 178, 77, 240, 161, 223, 56, 149, 196, 237};           

byte[] maskKey = new byte[] { 230, 144, 119,210 };
            source.AddSegment(data, 0, 86, true);
            source.DecodeMask(maskKey, 0, 4);           

// optCode is !=2

string TextNotWorking = source.Decode(Encoding.UTF8, 0, 86);           

Console.WriteLine(TextNotWorking);           

// taken from WebSocketCommandInfo(WebSocketDataFrame frame)

data = DecodeMask(data, maskKey);           

// optCode is !=2

string TextWorking = Encoding.UTF8.GetString(data);           

Console.WriteLine(TextWorking);       

}

// Code taken from WebSocketCommandInfo::DecodeMask

static private byte[] DecodeMask(byte[] data, byte[] mask) 

      {           

                for (var i = 0; i < data.Length; i++)   {               

data[i] = (byte)(data[i] ^ mask[i % 4]);           

                 }

            return data;     

  }

Thanks,

SKB

Jan 5, 2012 at 4:04 PM

Correction in my previous sample code:

source.DecodeMask(maskKey, 0, 86);

 

I have found the bug in ArraySegmentList::DecodeMask @ line 586 change from 'index' to 'index++':

Changed code: startSegment.Array[i] = (byte)(startSegment.Array[i] ^ mask[index++ % 4]); 

Please patch it....

Thanks,

SKB

Jan 5, 2012 at 10:05 PM

I have found a concurrent issue with WebSocketSession::SendResponseAsync.

I have three connection, and sometime when I send message to all the three connections it will reach only one connection with three messages intended for other connection. This happens very often (with latest supersocket and superwebsocket codebase).

Please investigate the issue.

Thanks,

SKB 

Jan 6, 2012 at 12:11 AM

It may have a bug  in EnqueueSend and DequeueSend in DraftHybi10Processor class. I am not sure...

Coordinator
Jan 6, 2012 at 12:48 AM

I'll fix mask issue ASAP.

Coordinator
Jan 6, 2012 at 12:57 AM
skbaronia wrote:

I have found a concurrent issue with WebSocketSession::SendResponseAsync.

I have three connection, and sometime when I send message to all the three connections it will reach only one connection with three messages intended for other connection. This happens very often (with latest supersocket and superwebsocket codebase).

Please investigate the issue.

Thanks,

SKB 

Hi, please take a look at this issue which may helpful:

http://supersocket.codeplex.com/discussions/275777