Closed
Description
- Version: v7.9.0 & v6.9.4
- Platform: Linux ... x86_64 x86_64 x86_64 GNU/Linux/Centos v7.3
- Subsystem:
I've tried to connect to UDP multicast from nodejs cluster.
It failed on the second process.
We are getting this error:
dgram.js:503
throw errnoException(err, 'addMembership');
^
Error: addMembership EADDRINUSE
at exports._errnoException (util.js:1050:11)
at Socket.addMembership (dgram.js:503:11)
at Socket.<anonymous> (/install/multicastudp/test2.js:23:15)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
at Socket.emit (events.js:188:7)
at startListening (dgram.js:117:10)
at onHandle (dgram.js:200:9)
at shared (internal/cluster/child.js:105:3)
at Worker.send (internal/cluster/child.js:76:7)
Code we used:
const cluster = require('cluster');
const dgram = require('dgram');
const udpPort = 64000;
const addr = '239.0.0.1';
if(cluster.isMaster){
cluster.fork();
cluster.fork(); // << this process cause an error
}else{
console.log("process pid: " + process.pid);
var udpClient = dgram.createSocket({type:"udp4", reuseAddr:true});
udpClient.bind(udpPort, function(){
udpClient.addMembership(addr);
});
}