Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websocket server in chrome packaged app

Im building a websocket server in chrome packaged apps. I got everything working (handshake and recieving from client to server) but, when I try to send message from Server to Client it always get an error: "failed: A server must not mask any frames that it sends to the client."

This is my prepareMessage code:

  var sendText = _toUTF8Array(JSON.stringify(msg) + '\n');
  var aa;
  var buffer;
  if (sendText.length > 125) {
      if (sendText.length < 65536) {
          aa = new ArrayBuffer(4 + sendText.length);
          buffer = new Uint8Array(aa);
          buffer[0] = 129;
          buffer[1] = 126;
          buffer[2] = sendText.length >> 8;
          buffer[3] = sendText.length & 255;
          _arrayCopy(sendText, 0, buffer, 4, sendText.length);
      }
      else {
          aa = new ArrayBuffer(10 + sendText.length);
          buffer = new Uint8Array(aa);
          buffer[0] = 129;
          buffer[1] = 127;
          var len = new Uint8Array(8);
          len = _Uint64ToUint8(sendText.length);
          var tt = new Uint8Array(8);
          for (var i = 0; i < 8; i++)
          {
              tt[7 - i] = len[i];
          }
          _arrayCopy(tt, 0, buffer, 2, 8);
          _arrayCopy(sendText, 0, buffer, 10, sendText.length);
      }
  }
  else {
      aa = new ArrayBuffer(2 + sendText.length);
      buffer = new Uint8Array(aa);
      buffer[0] = 129;
      buffer[1] = sendText.length;
      _arrayCopy(sendText, 0, buffer, 2, sendText.length);
  }
  return aa;
like image 980
Caio Keto Avatar asked Jul 01 '13 14:07

Caio Keto


1 Answers

you should use wireshark to see what is wrong with your packets! take a look on https://github.com/mik3fly-4steri5k/groschat, i m currently working on websockets, and it perfectly working on google chrome.

like image 115
mik3fly-4steri5k Avatar answered Sep 21 '22 12:09

mik3fly-4steri5k