Closed
Description
- Version: 4, 5, 6, (7, 8 maybe?)
- Platform: linux
- Subsystem:
when master to worker with some data with socket
and worker sends the received data to the master back with socket,
if the data size is above 10KB the socket disappeared.
here is the sample code
const cluster = require('cluster');
const net = require('net');
var doWork = function(worker) {
var sock = new net.Socket();
// available port and host
sock.connect(443, 'google.com', function() {
var data = [];
for(var i=0; i<30000; i++) {
data[i] = '1';
};
// 1. send to worker data with socket
console.log('master to worker with socket %s', sock);
worker.send({cmd:'syn', data:data}, sock);
});
};
if ( cluster.isMaster ) {
var num = 5;
var workers = [];
for(var i=0; i<num; i++) {
workers[i] = cluster.fork();
workers[i].on('message', function(m, h) {
// 3. received from worker, socket is undefined.
console.log('admin recv m %s, h %s, isNS', m.cmd, h, h? h instanceof net.Socket : 'na');
});
}
for(var i=0; i<num; i++) {
doWork(workers[i]);
}
} else {
process.on('message', function(m, h) {
// 2. worker send data to master with socket
console.log('worker m %s, h %s, isNS', m.cmd, h, h ? h instanceof net.Socket : 'na');
process.send({cmd:'ack', data:m.data}, h);
});
}