Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
sending websocket message greater than 64kB causes Ratchet websocket server to throw 'Underflow exception'

i have a websocket server written in php using ratchet websocket, and the clients are written in javascript creating websocket connection to connect to the php websocket server.

Client and server are communicating via json string, i found that when the json message size is greater than 64kB, the ratchet server would throw an 'underflow exception'

'UnderflowException' with message 'Frame must be coalesced before applying mask'

php server code

use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\Socket;

$server = IoServer::factory(
    new HttpServer(
        new WsServer(
            new Socket()
        )
    ),
    8080
);

$server->run();

javascript client

var socket  = new WebSocket('ws://123.123.123.123:8080');

let reader = new FileReader();
reader.onload = function() 
{
    sendPackageImageFile(reader.result);
};

reader.onerror = function() 
{
    console.log('reader.error');
};  

reader.readAsDataURL('some-file');


function sendPackageImageFile(imageFileData)
{
    var message = {};
    message.sender = 'someUser';
    message.action = 'send-package-image';
    message.packer = 'packer';
    message.data = 'some data';
    message.file = imageFileData;
    const js = JSON.stringify(message);
    socket.send(js);
}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!