[zeromq-dev] Reconnecting the Client side of a REQ-REP socket
Luca Boccassi
luca.boccassi at gmail.com
Fri Mar 23 12:36:25 CET 2018
On Thu, 2018-03-22 at 21:53 -0400, Jasper Jaspers wrote:
> In my application (C++ / Linux / zeromq 4.2) there are several
> sockets
> within a single context. Some of the REQ-REP sockets have transient
> servers and the clients need to be reconnected gracefully and quickly
> when
> the servers change. I'm having problems reconnecting the client side
> of
> the REQ-REP socket when the server side changes. The client's REQ
> socket
> is stuck waiting for a reply from the server's REP socket that it
> never
> gets.
>
> I have a way of notifying the client that the server has changed and
> it
> needs to reconnect, however I don't know how to unblock the client's
> receive call ( waiting for the reply). I do have a timeout set on
> receive
> call but I'd like to have the client reconnect a lot sooner than
> waiting
> for the timeout to expire before reconnecting. I see that calling
> zmq_term() on the context should unblock the receive call, but I
> can't use
> that since I have other connected sockets within the context that I
> don't
> want to disrupt. Does anyone have a suggestion on how to resolve
> this?
If the endpoint stays the same look at the heartbeats options.
If the endpoint changes, you'll need to zmq_disconnect and zmq_connect
--
Kind regards,
Luca Boccassi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180323/f3086a95/attachment.sig>
More information about the zeromq-dev
mailing list