Ensure that a stream disconnects if it goes over maxBytes
perSeconds
Stream-valve development was sponsored by Redsmin, a fully loaded administration service for Redis.
npm install stream-valve
var valve = require('stream-valve');
socket = net.connect(6379, '127.0.0.1');
socket.on('error', function(err){
// if valve maximum is reached a ESOCKETOVERFLOW error
// will be emitted and the socket will be destroyed.
});
// disconnect the socket if it receive more than 1MB per 2 seconds
valve(socket, 1024 * 1024, 2);
socket.on('data', function(){
// ...
});
I maintain this project in my free time, if it helped you please support my work via paypal or bitcoins, thanks a lot!