JustinTulloss/zeromq.node

Not receiving message when using 'inproc' protrocol

Closed this issue · 5 comments

Hi!

Assuming that 'push.bindSync' and 'pull.connect' are called with the same address. When using an address with 'tcp' protocol, the following code works properly. However, when using 'inproc' protocol, the message is not received.

Is it supposed to work that way?

const zmq = require('zmq'); // version: 4.2.0
const push = zmq.socket('push');
const pull = zmq.socket('pull');

const notWorkingWithThisAddress = 'inproc://address1';
//const workingWithThisAddress = 'tcp://127.0.0.1:3000';

push.bindSync(notWorkingWithThisAddress);
pull.connect(notWorkingWithThisAddress);

push.send(123);
pull.on('message', function() {
  // not called when using 'inproc' protocol.
  // However, this is called when using tcp.
  done();
});

I honestly couldn't tell you if this behavior is expected or not. ZMQ docs on either inproc behavior or push/pull may give you more information. Have you looked into that yet?

Also, if you move the send to below your message listener registration, does it start working?

Also, if you move the send to below your message listener registration, does it start working?

No, it doesn't.

The problem seems to be related to the arrangement of bindSync and connect call. Then, this works:

// works!
pull.bindSync(address);
push.connect(address);

This one works too:

// works!
pull.connect(address);
push.bindSync(address);

However, does anyone know why the two arrangements above work and the arrangements below do not?

// does not work!
push.connect(address);
pull.bindSync(address);

This one does not work too:

// does not work!
push.bindSync(address);
pull.connect(address);

So far, I read some explanations like the one below from the official guide (http://zguide.zeromq.org/page:all), but I didn't find the missing information to solve the puzzle.

If you're using inproc, make sure both sockets are in the same context. Otherwise the connecting side will in fact fail. Also, bind first, then connect. inproc is not a disconnected transport like tcp.

Are you sure your tests are 100% consistent? You can run the same tests many times and the result is always the same? The same tests either always work or always fail?

I double-checked the tests and they seem to be consistent. I also shared them here: https://gist.github.com/lucianojfj/d230261cd7a3c1390ebd25fd5b91a587

If possible, could you run them?

Thanks

I have run the same tests and other tests with node-nanomsg (https://github.com/nickdesaulniers/node-nanomsg) and all worked as expected. So far, the node-nanomsg seems to work more consistent. For now, I am giving up this binding (zeromq.node).