Skip to content

UDP multicast in the cluster does not work  #12572

Description

@srdjanarsic
  • 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);
  });

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clusterIssues and PRs related to the cluster subsystem.dgramIssues and PRs related to UDP and the dgram module.docIssues and PRs related to Node.js documentation.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions