[zeromq-dev] [Q] proper message sequence for XREQ to XREP and back again

Chuck Remes cremes.devlist at mac.com
Wed Aug 25 21:16:34 CEST 2010

I have a client (XREQ socket) that connects to a server (XREP socket) via an intermediary Forwarder device proxy (XREP & XREQ bound to different ports).

I can successfully send data from the client to the server. I see the traffic flow through each step by printing the message contents inside the forwarder.

However, on the return leg from the server to the client, the response never makes it to the client. I see it get received by the forwarder but then it disappears.

Reading through the updated docs (thanks for XREQ and XREP docs!) it mentions a delimiter message part which is I guess a null message created by zmq_msg_init. The docs mention that when talking from XREQ to REP or from XREP to REQ, this delimiter message part must be present to separate the identities for routing from the body.

Do I need to manually recreate that when communicating between XREQ and XREP sockets?

My message flow looks like this:

1. Client sends single body message part via XREQ.

2. Forwarder receives all message parts from client on XREP socket.

3. Forwarder rewrites those exact messages to the outbound XREQ socket.

4. Server receives message parts on XREP socket. Server saves the first message part for return routing.

5. Server sends routing message part + body message part via XREP socket.

6. Forwarder receives reply on XREQ socket. 

7. Forwarder rewrites reply to XREP socket connected back to client. Data never makes it to the client.

I have tried adding a null message part in Step 5 (send route ID, null part, body part) but that didn't help.

Any ideas on how to fix this? I'm using 2.0.8.


More information about the zeromq-dev mailing list