javascript - ZeroMQ with node.js pipeline sink stops receiving messages after a while -
i've been trying set ventilator / worker / sink pattern in order crawl pages, never got past testing phase. 1 particularity of setup sink lives in same process ventilator. nodes utilize ipc:// transport. moment test messages exchanged. ventilator sends tasks, workers receive them , wait send confirmation sink.
symptoms: after time (generally less 5 minutes) sink stops receiving confirmation messages though ventilator keeps on sending tasks , workers maintain on receiving them , sending confirmations messages.
i know confirmations sent because if restart sink, gets missing messages on startup.
i thought zeromq dealt auto-reconnect.
ventilator/sink
var force = 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 tried moving sink process , seems work. live in same process , observed similar behaviour when dealing more 1 zmq socket per process, regardless of pattern used
edit i'm using module https://github.com/justintulloss/zeromq.node
i don't expect reply accepted, i'm placing here reference. there faithful node-only module called axon inspired zeromq.
axon has no compiled dependencies, , re-creates same socket types zeromq. axon builds upon pub/sub socket type create network event-emitter. finally, zmqs req/rep socket not work node.js because zmq expects reply occur synchronously. beingness native node, axon library handles req/rep pattern properly.note: zmq , axon not interoperable.
javascript node.js zeromq pipeline
No comments:
Post a Comment