When calling pub.unregister we get warning messages that look like that:
[WARN] [1544525264.664350]: Could not process inbound connection: [/pub_bug] is not a publisher of [/topic2]. Topics are [['/rosout', 'rosgraph_msgs/Log']]{'message_definition': 'string data\n', 'callerid': '/pub_bug', 'tcp_nodelay': '0', 'md5sum': '992ce8a1687cec8c8bd883ec73ca41d1', 'topic': '/topic2', 'type': 'std_msgs/String'}
This script tries to reproduce the error in various conditions to locate where the issue comes from
pub1 is publishing on topic1 with no subscriber.
When calling pub1.unregister() no warning messages appear.
While pub1 is still publishing on topic1,
when subscribing from outside rostopic echo /topic1,
and then unscubscribing by killing the rostopic echo before pub1.unregister is called
we have no warning messages
pub2 is publish on topic2 with one subscriber.
When calling pub2.unregister() we receive warning messages.
pub3 is commented out. But when uncommented. It publishes on topic2 like pub2.
When calling pub2.unregister() we receive NO warning messages.
In both cases: pub3 commented and uncommented.
When you try to create a new publisher on topic2 (with recreate_pub2), no callback are made.
In any case, before and after calling pub2.unregister(),
the subscriber on topic2 receives callbacks of messages from other nodes
After the pub2 is re-created, when calling rostopic echo /topic2
We receive no messages from the pub2 publisher.
- When calling
pub.unregister, if we have no subscriber then the call is successful. - Failure to call
pub.unregisterblocks further publishers from this node to publish to the same topic