Client losing messages with (modified) example
Opened this issue · 2 comments
cly commented
Running this will over time produce discrepancies between what is sent by producer and what is received by the worker. Is this expected? Is there a way to see what the cause is? worker not ready? buffer overflow? producer not sending data?
producer.js
var zmq = require('zmq')
var sock = zmq.socket('push')
sock.bindSync('tcp://127.0.0.1:3000')
console.log('Producer bound to 3000')
var count = 0
setInterval(function() {
count++
if (count % 100000 === 0) {
console.log('sending work' + count)
}
sock.send('' + count)
})
worker.js
var zmq = require('zmq')
var sock = zmq.socket('pull')
sock.connect('tcp://127.0.0.1:3000')
console.log('work connected to port 3000')
var messagesReceivedCount = 0
sock.on('message', function(msg) {
messagesReceivedCount++
var producerCount = +msg
console.log(messagesReceivedCount, producerCount, (producerCount - messagesReceivedCount))
})
pronebird commented
setInterval
with no interval?
cly commented
It's just trying to send messages as quickly as it can. Similar to a while(true)
.