This repository has been archived by the owner. It is now read-only.

CLUSTER Module: "Error Address in use" - [Not able to share tcp address with worker processes] #5188

Closed
amolmk opened this Issue Apr 1, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@amolmk

amolmk commented Apr 1, 2013

var zmq = require('zeromq.node');
var pull_socket = zmq.socket('pull');
var cluster = require('cluster');
var numCPUs = require('os').cpus().length;

//**** CLUSTER module : Stability: 1 - Experimental ****/
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('online', function (worker) {
console.log("The worker responded after it was forked");
});
cluster.on('listening', function (worker, address) {
console.log("A worker is now connected to " + address.address + ":" + address.port);
});
cluster.on('disconnect', function (worker) {
console.log('The worker #' + worker.id + ' has disconnected');
});
cluster.on('exit', function (worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
pull_socket.bind('tcp://127.0.0.1:12345', function (err) {
if (err) console.error(err);
else {
console.log("[worker " + cluster.worker.process.pid + "] Listening...");
pull_socket.on('message', function (data) {
console.log(data);
});
}
});
}

Output:
The worker responded after it was forked
The worker responded after it was forked
The worker responded after it was forked
The worker responded after it was forked
[Worker 2648] Listening...
Error: Address in use
Error: Address in use
Error: Address in use

Why it says "Error: Address in use"?
Its mentioned in docs that, "Workers can share any TCP connection".
link: http://nodejs.org/api/cluster.html#cluster_cluster

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Apr 1, 2013

Member

Closing, invalid. Report this to the author(s) of the zeromq bindings.

Its mentioned in docs that, "Workers can share any TCP connection".

Created by node.js. Connections created by native add-ons are not under node's control.

Member

bnoordhuis commented Apr 1, 2013

Closing, invalid. Report this to the author(s) of the zeromq bindings.

Its mentioned in docs that, "Workers can share any TCP connection".

Created by node.js. Connections created by native add-ons are not under node's control.

@bnoordhuis bnoordhuis closed this Apr 1, 2013

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