Incorrect reply routing for ZMQ_REP/ZMQ_XREP socket
Description
Environment
x86_64 CentOS Linux release 6.0 (Final)
g++ (GCC) 4.4.4 20100726 (Red Hat 4.4.4-13)
zeromq-2.1.10
Attachments
3
Activity
Show:
Andrey S. January 19, 2012 at 11:38 AM
Hi.
Do you have news about this issue?
Andrey S. January 13, 2012 at 6:21 AM
Two clients sends messages with cliendId (0 and 7 in log) to the server. Server send reply with same content as reqest.
As I understood for REQ/XREP sockets each reply should be sent to client who sent the request.
So, in this case send() should delivery reply to requested client. Is it true?
But second client receives messages with id=0 and id=7. I.e. second client receives server replies for first client.
Martin Sustrik January 12, 2012 at 10:43 PM
Yes. It's not clear what the expected result is and what you get instead. More explanation would help.
Staffan Gimåker January 12, 2012 at 10:26 PM
I can't really understand the issue you're experiencing from your report. Clarify?
In accordance to the zmq socket description:
Each request received is fair-queued from among all clients, and each reply sent is routed to the client that issued the last request.
I use modified examples from http://www.zeromq.org/blog:multithreaded-server
http://www.zeromq.org/local--files/blog:multithreaded-server/server.cpp
http://www.zeromq.org/local--files/blog:multithreaded-server/client.cpp
Server running with one worker thread. Also two clients sends messages to server. First client without delay, second with delay 1 second between messages.
Each client sends messages with last digit of him pid. For example
Hello message: 0 7
7 - part of pid
Server sends reply with same message.
Example of second client output:
Recv msg 18: Hello message: 6 0
Send msg: OK
Recv msg 18: Hello message: 3 7
Send msg: OK
Recv msg 18: Hello message: 8 0
Send msg: OK
Recv msg 18: Hello message: 7 0
Send msg: OK
Recv msg 18: Hello message: 4 0
Send msg: OK
Recv msg 18: Hello message: 7 7
Send msg: OK
Recv msg 18: Hello message: 8 7
Send msg: OK
Recv msg 18: Hello message: 9 7
So, first client recives а replies for first client (end of pid 0)