Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Disconnection events on SUB socket? #201

Open
ogabrielides opened this issue Nov 14, 2024 · 4 comments
Open

Detect Disconnection events on SUB socket? #201

ogabrielides opened this issue Nov 14, 2024 · 4 comments

Comments

@ogabrielides
Copy link

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?

@Bombadad
Copy link

Bombadad commented Nov 14, 2024 via email

@ogabrielides
Copy link
Author

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

@jmcphers
Copy link

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:

zmq.rs/src/rep.rs

Lines 93 to 98 in 07c65dc

fn peer_disconnected(&self, peer_id: &PeerIdentity) {
if let Some(monitor) = self.monitor().lock().as_mut() {
let _ = monitor.try_send(SocketEvent::Disconnected(peer_id.clone()));
}
self.peers.remove(peer_id);
}

However, SUB sockets do not do this.

zmq.rs/src/sub.rs

Lines 110 to 112 in 07c65dc

fn peer_disconnected(&self, peer_id: &PeerIdentity) {
self.peers.remove(peer_id);
}

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

@WillPCowan
Copy link

WillPCowan commented Jan 23, 2025

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants