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 · 3 comments
Open

Detect Disconnection events on SUB socket? #201

ogabrielides opened this issue Nov 14, 2024 · 3 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?

@CableSynth
Copy link

CableSynth 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.

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

3 participants