zmq.rs icon indicating copy to clipboard operation
zmq.rs copied to clipboard

Detect Disconnection events on SUB socket?

Open ogabrielides opened this issue 1 year ago • 6 comments

How to detect Disconnection event on a PUB socket?

I used:

let mut monitor = socket.monitor(); and monitor.try_next() on a thread. The only event that I got is SocketEvent::Connected even if I manually stopped the Publisher side on purpose.

How to detect SocketEvent::Disconnected?

ogabrielides avatar Nov 14 '24 11:11 ogabrielides

Hmm I'll have to try this out. I've been wanting to see if these work.

On Thu, Nov 14, 2024, 06:32 Odysseas Gabrielides @.***> wrote:

How to detect Disconnection event on a PUB socket?

I used:

let mut monitor = socket.monitor(); and monitor.try_next() on a thread. The only event that I got is SocketEvent::Connected even if I manually stopped the Publisher side on purpose.

How to detect SocketEvent::Disconnected?

— Reply to this email directly, view it on GitHub https://github.com/zeromq/zmq.rs/issues/201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIQCA63DE54O6H73UJXNPL2ASC3TAVCNFSM6AAAAABRYVWNQSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGY2TQNJUGU2DIMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Bombadad avatar Nov 14 '24 11:11 Bombadad

@CableSynth Cool, let me know if you manage to do this

ogabrielides avatar Nov 14 '24 12:11 ogabrielides

It looks like this might not be implemented? If you look at REP sockets, they send a Disconnected event to the monitor when the peer disconnects:

https://github.com/zeromq/zmq.rs/blob/07c65dcfca2cc8189af852346c0da60da540027d/src/rep.rs#L93-L98

However, SUB sockets do not do this.

https://github.com/zeromq/zmq.rs/blob/07c65dcfca2cc8189af852346c0da60da540027d/src/sub.rs#L110-L112

I'm not a ZeroMQ expert but this may just be an oversight.

jmcphers avatar Dec 23 '24 17:12 jmcphers

Also haven't found a way to get a subscriber to understand that a publisher has disconnected. I can make an application level solution but this would only work if the publisher gracefully shuts down...

This is essential for implementing robust services/applications so priority should be high imo; I need this ASAP so could try and contribute but don't see any guidelines/support docs? (I guess the answer is just to get stuck in)

WillPCowan avatar Jan 23 '25 21:01 WillPCowan

The same issue exist on PUB sockets. I am working on a PR.

gvz avatar May 09 '25 09:05 gvz