I've been trying to set up a ventilator / worker / sink pattern in order to crawl pages, but I never got past the testing phase. The one particularity of my setup is that the sink lives in the same process as the ventilator. All nodes use ipc:// transport. For the moment only test messages are exchanged. the ventilator sends tasks, workers receive them and wait then send a confirmation to the sink.
Symptoms: After some time (generally less than 5 minutes) the sink stops receiving confirmation messages even though the ventilator keeps on sending tasks and workers keep on receiving them and sending confirmations messages.
I know that confirmations are sent because if I restart my sink, it gets all the missing messages on startup.
I thought ZeroMQ dealt with auto-reconnect.
ventilator/sink
var push = zmq.socket('push');
var sink = zmq.socket('pull');
var pi = 0;
setInterval(function() {
push.send(['ping', pi++], zmq.ZMQ_SNDMORE);
push.send('end');
}, 2000);
push.bind('ipc://crawl.ipc');
sink.bind('ipc://crawl-sink.ipc');
sink.on('message', function() {
var args = [].slice.apply(arguments).map(function(e) {return e.toString()});
console.log('got message', args.join(' '));
});
worker.js
var pull = zmq.socket('pull');
var sink = zmq.socket('push');
sink.connect(opt.sink);
pull.connect(opt.push);
pull.on('message', function() {
var args = [].slice.apply(arguments).map(function(e) {return e.toString()});
console.log('got job ', args.join(' '));
setTimeout(function() {
console.log('job done ', args.join(' '));
sink.send(['job done', args.join(' ')]);
}, Math.random() * 5 * 1000);
});
EDIT I tried moving the sink to another process and it seems to work. However I would really like it to live in the same process and I observed similar behaviour when dealing with more than one zmq socket per process, regardless of the pattern used
EDIT I'm using this module https://github.com/JustinTulloss/zeromq.node
I don't necessarily expect this answer to be accepted, but I'm placing it here for reference. There is a very faithful node-only module called Axon which is inspired by ZeroMQ.
Note: ZMQ and Axon are not interoperable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With