[zeromq-dev] recv in REQ client blocks forever if XREP server dies

Troy Gutjahr zmq-devlist at troy.cygnusconnect.com
Sun Dec 5 08:23:29 CET 2010


How can a REQ client detect that an XREP server has died? For
example, if you run the hwserver and hwclient example programs on
Linux and kill the hwserver before hwclient has finished sending
and receiving all of its messages, the hwclient program blocks
forever in recv like this:

#0  0x0060d416 in __kernel_vsyscall ()
#1  0x00a7f8f8 in recv () at
../sysdeps/unix/sysv/linux/i386/socket.S:97
#2  0x0038abdc in recv (this=0x9b1ac24, cmd_=0xbf913ae8,
block_=true)
    at /usr/include/bits/socket2.h:45
#3  zmq::mailbox_t::recv (this=0x9b1ac24, cmd_=0xbf913ae8,
block_=true)
    at mailbox.cpp:203
#4  0x003964a2 in zmq::socket_base_t::process_commands
(this=0x9b1ab90,
    block_=true, throttle_=128) at socket_base.cpp:618
#5  0x003966ee in zmq::socket_base_t::recv (this=0x9b1ab90,
msg_=0xbf913bb4,
    flags_=0) at socket_base.cpp:526
#6  0x003a03ef in zmq_recv (s_=0xfffffe00, msg_=0xbf913bb4,
flags_=0)
    at zmq.cpp:341
#7  0x08048c90 in main ()

I want to develop a reconnection strategy in my client program so
that whenever the XREP server terminates and restarts, the client
will get an error and then repeatedly retry connecting to the
server. Alternatively, I would like the new instance of the
server to take over the previously established XREP end of the
connection and start handling the next request from the clients.

I'm doing this with C++ (gcc 4.4.5), Ubuntu 10.10 on X86 and
ZeroMQ 2.1.0.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101205/23b11c72/attachment.htm>


More information about the zeromq-dev mailing list