[zeromq-dev] Reconnecting the Client side of a REQ-REP socket
Jasper Jaspers
jaspers01995 at gmail.com
Fri Mar 23 13:54:59 CET 2018
On the client side there are two threads. Thread1 continually issues the
zmq_send followed by zmq_recv. Thread2 detects that the endpoint has
changed. When thread2 detects the endpoint has changed I'd like to unblock
thread1 that's currently waiting for zmq_recv to finish. Is it possible to
have thread2 issue a zmq_disconnect to unblock the zmq_recv in thread1?
On Fri, Mar 23, 2018 at 7:36 AM, Luca Boccassi <luca.boccassi at gmail.com>
wrote:
> 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
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180323/9b7e0300/attachment.htm>
More information about the zeromq-dev
mailing list