how to set maximum size limit for incoming socket.io message

we want our server to block any messages that contain data larger than 7 kb.

our serverside code:

socket.on('startdata', function (data) {

        console.log(data.text);});

our clientside code:

        socket.emit('startdata', { text: 'testtext blah blah' });

is there a way to check the data size and refuse to accept the message before the data gets passed to the socket.on function ?

I was also curious about this and did some digging.

It seems destroy buffer size is available for use which defaults to 100mb

important note: Used by the HTTP transports. The Socket.IO server buffers HTTP request bodies up to this limit. This limit is NOT applied to websocket or flashsockets. (https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO)

So sadly, it won't work with the websockets or flashsockets. Someone did try a pull request for this though: https://github.com/LearnBoost/socket.io/pull/888