0MQ req wait for rep in Node.js

I'm new to javascript, Node.js and 0MQ, so n00b * 3 is here.

I want to set up a simple request and respond, but I want the client to wait for a response before sending the next request.

zguide goes through this, but Node.js doesn't behave like C (which is what I want).

I realize that I am struggling with a paradigm shift here when I look at the problem, but I still feel like I should. Can I make a call recv

(or something similar) in the client?

+3


source to share


1 answer


You're right, the ZMQ version of node.js doesn't behave the way you'd expect if you came from the C version, but it actually behaves according to the rules, it's just adding some of your sauce to the mix.

In particular, C bindings will throw an error if you try to break the strict REQ / REP / REQ / REP loop. In node.js, it will cache the error message until the previous response returns, then post this new message ... so you still get REQ / REP / REQ / REP so that, and you can post the message whenever you want , no mistakes.



This is probably a poor design choice on the part of the authors of the node ZMQ binding, primarily because it confuses new users like you, and secondly, if you are using REQ / REP, you would probably prefer hard crashing if you fail otherwise you will be using a different socket type.

+2


source







All Articles