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?
use buffer size
require('socket.io')(server, {
maxHttpBufferSize: 1e9
});
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.