When using Perl's Websocket server, if I send a json message using send_utf8 that's longer than about 16,000 characters, it causes the connection to the websocket to be killed in Chrome with the message:
"Could not decode a text frame as UTF-8".
Is there some restriction on the length of messages that can be sent by this Websocket server, and is there a way of getting around this restriction?
It fails because (as of 0.001003) Net::WebSocket::Server::Connection initializes its Protocol::WebSocket::Frame objects without setting "max_payload_size" which overrides the 65535 byte limit. The problem can be easily resolved if the module author updates those calls to allow larger buffers, or better, to pass through a user defined value.
Apparently, it's possible to set the payload size in the Protocol::WebSocket::Frame constructor (https://github.com/vti/protocol-websocket/issues/24#issuecomment-27095561).
Unfortunately the docs on cpan seem to be missing that information.
Try this:
$hs->build_frame(buffer => $my_data, max_payload_size => 200000)->to_bytes);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With