You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I want to know if my pub socket has any subscribers at all. So it can stop it's work and avoid wasting resources when no one is listening
Describe the solution you'd like
Some way to get notified on subscribe/unsubscribe of clients. Extra niceness would be if you can get the topics they are subscribed to.
Describe alternatives you've considered
some way to get the current subscriber count && polling that would also work, I guess.
It is possible to obtain the entire list of connected subscribers via pipe event hooks. (see nng_pipe_notify()).
However, for PUB sockets, it is not possible to know their subscriptions. That's because this pattern is very simply a receiver (subscriber) side filter. The publisher has no idea about subscriptions it just sends every message out that it is asked, to every subscriber. (Changing that behavior would require publisher side filtering, for which there is already a ticket filed. Publisher side filtering would require a complete rearchitecture of this pattern, and presents substantial design challenges (because of nng_device() type proxies). I still plan to do it someday, but I have to have enough cycles to spend on it, and $dayjob is keeping me otherwise occupied at present.
With your hint I was able to find sock.add_post_pipe_connect_cb() and sock.add_post_pipe_remove_cb() in the python implementation which does take care of the subscriber tracking.
I was surprised to hear that filtering is client-side and not publisher-side. I did not expect this - it makes filtering a bit uninteresting for me.
I totally understand that you are busy with other things. I've subscribed to #1473 in the hopes this gets implemented at some time.
Is your feature request related to a problem? Please describe.
I want to know if my pub socket has any subscribers at all. So it can stop it's work and avoid wasting resources when no one is listening
Describe the solution you'd like
Some way to get notified on subscribe/unsubscribe of clients. Extra niceness would be if you can get the topics they are subscribed to.
Describe alternatives you've considered
some way to get the current subscriber count && polling that would also work, I guess.
Additional context
Similar to this ZMQ XPUB feature: https://gist.github.com/minrk/2296266
The text was updated successfully, but these errors were encountered: