Hi Milosz: I dislike it when someone asks a “How do I do X”? question and the replies are all about how NOT to do X, but in this case I can’t help it — sorry:
- You may want to re-think REQ/REP. In practice, REQ/REP has been found to be somewhat fragile (https://stackoverflow.com/questions/26915347/zeromq-reset-req-rep-socket-state <https://stackoverflow.com/questions/26915347/zeromq-reset-req-rep-socket-state>). With recent versions of the library the ZMQ_REQ_RELAXED socket option may help. - The zmq_socket_monitor functionality was never intended for driving state changes in an application, but rather for logging and trouble-shooting purposes. In particular, the zmq_socket_monitor events are asynchronous (the docs state in several places "Warning: there is no guarantee that the FD is still valid by the time your code receives this event.”). In addition, the underlying connect/disconnect events are themselves asynchronous (i.e., calling zmq_connect simply starts the connection process — it may take an arbitrary length of time to complete). If you need to track connection state reliably, you are going to have to implement some connection-tracking mechanism “on top of” ZeroMQ, possibly using application-level heartbeats, timeouts, etc. This can get quite messy, but as far as I know is the only way. Hope this helps. Bill Torpey > On Jun 3, 2019, at 5:41 AM, Milosz Malczak <[email protected]> wrote: > > I am creating a distributed system with one server and many peers. For > communication I am using ZeroMQ, REQ-REP pattern. In order to be able to > detect that the connection was lost I am using socket_monitor. The problem is > that, when I get the message about disconnection, I don't know how I can tell > which peer was actually disconnected. The only information that allows to > distinguish the connections is the file descriptor, which I receive from the > socket_monitor, but I don't know which connection/peer it belongs to. > _______________________________________________ > zeromq-dev mailing list > [email protected] <mailto:[email protected]> > https://lists.zeromq.org/mailman/listinfo/zeromq-dev > <https://lists.zeromq.org/mailman/listinfo/zeromq-dev>
_______________________________________________ zeromq-dev mailing list [email protected] https://lists.zeromq.org/mailman/listinfo/zeromq-dev
