proxy multiple proxies by net.createServer
here is my all code
var proxies='127.0.0.1:4444,127.0.0.1:4443,127.0.0.1:4442'.split(',');
var net = require('net');
function randgetir(){
d=proxies[Math.floor(Math.random() * proxies.length)].split(':');
return [d[0],d[1]];
}
var cre=net.createServer(function(from) {
var prgs=randgetir();
var to = net.createConnection({host: prgs[0],
port: prgs[1]
}).on('error', function(error) {
});
from.pipe(to);
to.pipe(from);
}).on('error', function(error) {
});
cre.listen("56666");
when i run the code sometimes i get
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:162:27)
Emitted 'error' event at:
at errorOrDestroy (internal/streams/destroy.js:98:12)
at Socket.onerror (_stream_readable.js:720:7)
at Socket.emit (events.js:197:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
error and my app just crash and exit but as you see i handle all the error events,
what may i be doing wrong?