My colleagues and I had the issue that sometime ros2 topics were not shown in “ros2 topic list” or that we could not “ros2 topic echo” the data. After further investigation, we concluded that the problem occurred when we connected/disconnected new devices to the network ports after the ROS2 nodes were already running. We are able to reproduce 2 cases:
Direct connection to network port, no switch in between.
The problem is shown with any DDS vendor. The only thing that solves these problems is a restart of the ros2 daemon and a restart of the ROS2 nodes. (ros2 daemon restart alone is not sufficient)
My first conclusion in case 1 is that the DDS is not performing a new discovery into the new active network interface. For case 2, I am still unsure what the problem is, but it seems that the DDS creates a dependency on the network interface connected at start.
@Renzo_Ba thanks for posting the details here, that is really helpful what could happen changing network interfaces at runtime.
and this is know behavior. i think basically it depends on RMW implementation (e.g DDS) and IP routing configuration. all of the situation described here is that endpoints cannot communicate with each other because they are using different network interfaces. ROS 2 is not aware of these network configuration change during runtime, so we need to restart the ROS 2 node in these cases.
@tomoyafujita thank you for the response. This indeed clears up our doubts.
Then we will have to use a static network setup for now before we start our ROS2 nodes. A switch also solves part of our problems as it keeps the network interface active and we can connect and disconnect devices from it.