zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

Deferral of peer subscriber undeclarations

Open fuzzypixelz opened this issue 2 months ago • 1 comments

Describe the bug

Peers act as if they were brokers between their clients and their peers: when a peer receives a subscriber undeclaration from its client it will not propagate it to other peers if one of them still subscribes to it, instead it will only propagate it to the last subscriber.

This means that one of the non-subscriber peers would wrongly route publications to the "deferring" peer.

To reproduce

The following is a script to reproduce this issue in Nuze. Here's the packet capture as well: scenario.pcapng.zip

#!/usr/bin/env nuze --no-default-session

# This peer-to-peer pub/sub scenario demonstrates how a peer subscriber undeclaration can be deferred
# and lead to unecessary routing of publications (i.e. when there is no subscriber on the other end).
# See https://github.com/eclipse-zenoh/zenoh/blob/7d93d422ac5533c23c8958502280d15e5e01f18b/zenoh/src/net/routing/hat/p2p_peer/pubsub.rs#L274-L295

zenoh open -s p1 {id:'1'}
zenoh open -s p2 {id:'2'}
zenoh open -s p3 {id:'3'}
sleep 100ms

let s2 = job spawn {zenoh sub -s p2 ke}
let s3 = job spawn {zenoh sub -s p3 ke}
sleep 100ms

zenoh put -s p1 ke 'this should be transmitted to 2 and 3'
sleep 100ms

job kill $s2
sleep 100ms

# Bug: this will be tranmitted to 3 and 2 (see packet capture)
zenoh put -s p1 ke 'this should be transmitted to 3 but not 2'
sleep 100ms

job kill $s3
sleep 100ms

zenoh put -s p1 ke 'this should not be transmitted'
sleep 100ms

zenoh session close -s p1
zenoh session close -s p2
zenoh session close -s p3

System info

  • ref: 1.6.2

fuzzypixelz avatar Nov 03 '25 11:11 fuzzypixelz

cc @OlivierHecart.

fuzzypixelz avatar Nov 03 '25 11:11 fuzzypixelz