zenoh
                                
                                 zenoh copied to clipboard
                                
                                    zenoh copied to clipboard
                            
                            
                            
                        Peer Heartbeat
Peer Heartbeat (API)
Does Zenoh have an internal heartbeat to detect if peers are no longer available? Please correct me if I overlooked such or similar functionality.
If yes, would it be possible to make changes to the network topology (e.g. UDP peers gone missing) available via the API?
If no, would you consider implementing a heartbeat, or should this rather be implemented in "user-land" (on top of zenoh)?
In my usecase I have (potentially) long-running tasks that are started remotely using a zenoh query. I have to detect if the task execution (process) crashes or the network becomes unavailable. Vice-versa the task executor needs to know if the caller becomes unavailable, because in this case the task has to be canceled. My first go-to would be implementing a heartbeat in the form of periodical queries, but I would prefer a better/more efficient/built-in solution.
Hi,
Zenoh does have a heartbeat, which manifests in a few ways:
- While topology changes are technically exposed directly through an adminspace topic, using that is currently discouraged as we haven't stabilized the connection events yet. I also can't vouch for the completeness of those events past direct connectivity.
- Liveliness tokens can be declared to expose to other peers that a functionality is reachable. Any node can subscribe to liveliness events, or query tokens in their own time. This is often enough the best mapping to what users are actually trying to solve, rather than checking that a given ID appears within the known nodes list.
- matching_statusis a new property of- Publishers which allows you to check whether or not subscriptions that your publisher would write to exist.
Based on your second message, I would say that liveliness tokens are probably the best fit for what you're trying to achieve. You can access their API through the session's liveliness method. While the API is still marked as unstable (our version of nightly: the feature works, but we might break API on it), I don't believe we have any gripes with it, so you can likely trust that it will be stabilized as-is by the next release.
Thanks for the fast reply! I was not aware of the liveliness method, sounds like that's exactly what I need. When do you expect that feature to arrive in the python bindings? (next release?)
I think they'll be in there for the next release, yeah. Probably much sooner on main, do you mind creating an issue on the Python bindings repo to make keeping track of this easier (and pinging you) for whoever does that once we get around to it? :)