Websocket connection length too large

478 views
Skip to first unread message

Julien

unread,
Apr 12, 2014, 8:44:46 PM4/12/14
to tot...@googlegroups.com
Hi Peter,

My controller send large data to websocket client but i have a problem
WebSocket connection to 'wss://127.0.0.1:8000/' failed: WebSocket frame length too large: 332308418702121151 bytes

Have you some parameter for the configuration framework.websocket

Thank you

Peter Širka

unread,
Apr 13, 2014, 12:14:24 PM4/13/14
to tot...@googlegroups.com
Hi Juline,
this exeption throws browser or total.js?

Thanks.

Julien

unread,
Apr 13, 2014, 1:44:57 PM4/13/14
to tot...@googlegroups.com
Browser Chrome on Mac OS

Peter Širka

unread,
Apr 13, 2014, 2:19:51 PM4/13/14
to tot...@googlegroups.com
Do you have some example? ... or write me some data which do you send via websocket.
Thanks.

Julien

unread,
Apr 27, 2014, 7:38:07 AM4/27/14
to tot...@googlegroups.com
WebSocket frame length too large: 531527972807532 bytes

Example:

Server side
controller.on('message', function(client, message) {

        // create a DB connection
        var connString = 'postgres://user:1234@localhost:5432/db';
        pg.connect(connString, function(err, client) {

            var sql = 'select * from "test" limit 300';
            client.query(sql, function(err, result) {

                if (err) {
                    console.log(err)
                    self.json(err);
                    return;
                }

                var featureCollection = new FeatureCollection();
                console.log(result)

                for (i = 0; i < result.rows.length; i++)
                {
                    featureCollection.features[i] = JSON.parse(result.rows[i].shape);
                }

                controller.send({ message: featureCollection });
                return;
            });
        });

Client side

socket.onmessage = function(e) {
            var jsonFeature = JSON.parse(decodeURIComponent(e.data)).message;
            var t = jsonFeature.toString();

andrea...@gmail.com

unread,
Jun 16, 2014, 2:24:05 PM6/16/14
to tot...@googlegroups.com
I have the same problem to send messages with length > 65535, I'm working to solve it, currently i've patched function getWebSocketFrameLengthBytes on utils.js :

lengthBuffer[1] = 0x00;
lengthBuffer[2] = 0x00;
lengthBuffer[3] = 0x00;
lengthBuffer[4] = 0x00;
lengthBuffer[5] = (length >> 24) & 255;
lengthBuffer[6] = (length >> 16) & 255;
lengthBuffer[7] = (length >> 8) & 255;
lengthBuffer[8] = (length) & 255;

this works but there is surely a problem how numbers are managed (32/64 bit? unsigned? ... I need to study it)

You will have the same problem receiving a message > 65535, the problem is when the parser calculates the message length.

Peter Širka

unread,
Jun 16, 2014, 2:27:28 PM6/16/14
to tot...@googlegroups.com, andrea...@gmail.com
Hi Andrea,

Do you have a latest version?
My friend updated WebSocket: long messages are splitted to frames.

Thanks.

andrea...@gmail.com

unread,
Jun 16, 2014, 4:38:27 PM6/16/14
to tot...@googlegroups.com, andrea...@gmail.com
Hi Peter,

I've updated to 1.5.3 via npm then I manually updated index.js and utils.js from git to check where the error was.

Can't see that part of frame splitting on WebSocketClient.prototype.send / utils.getWebSocketFrame


Do he fixed also the problem on receiving frames ?

Peter Širka

unread,
Jun 16, 2014, 4:46:29 PM6/16/14
to tot...@googlegroups.com, andrea...@gmail.com
Ahha, you have a problem with sending long messages, is that so?

andrea...@gmail.com

unread,
Jun 16, 2014, 4:51:55 PM6/16/14
to tot...@googlegroups.com, andrea...@gmail.com
On Monday, June 16, 2014 10:46:29 PM UTC+2, Peter Širka wrote:
> Ahha, you have a problem with sending long messages, is that so?

Well, sending and receiving, with my hack now I can send messages up to 4 Gb (int32, quite reasonable to me). I've to check by casting length to int64.

Now the issue is on receiving long messages, for example, base64 encoded image of about 250kb, everything else is working fine so I suppose the problem is now on WebSocketClient.prototype.parse.

Peter Širka

unread,
Jun 16, 2014, 4:53:39 PM6/16/14
to tot...@googlegroups.com, andrea...@gmail.com
I'll test it this week.
I'll give a feedback.

Thanks!
Reply all
Reply to author
Forward
0 new messages