ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS2 Talker cannot communicate with Listener

asked 2018-08-12 08:13:49 -0500

takijo gravatar image

updated 2018-09-08 23:42:48 -0500


I want to use ROS2.

I finished to setup ROS2,but talker cannot communicate with listener.

My setup is below.

$ sudo apt update && sudo apt install curl 
$ curl | sudo apt-key add -
$ sudo sh -c 'echo "deb [arch=amd64,arm64] xenial main" > /etc/apt/sources.list.d/ros2-latest.list'
$ sudo apt update
$ sudo apt install `apt list "ros-ardent-*" 2> /dev/null | grep "/" | awk -F/ '{print $1}' | grep -v -e ros-ardent-ros1-bridge -e ros-ardent-turtlebot2- | tr "\n" " "`

So, the terminal 1 is

$ source /opt/ros/ardent/setup.bash
$ ros2 run demo_nodes_cpp talker

and, the terminal 2 is

$ source /opt/ros/ardent/setup.bash
$ ros2 run demo_nodes_cpp listener

terminal 1 display

$ ros2 run demo_nodes_cpp talker
[INFO] [talker]: Publishing: 'Hello World: 1'
[INFO] [talker]: Publishing: 'Hello World: 2'
[INFO] [talker]: Publishing: 'Hello World: 3'
[INFO] [talker]: Publishing: 'Hello World: 4'
[INFO] [talker]: Publishing: 'Hello World: 5'

but ,terminal 2 no response.

What am I wrong?

(I use Ubuntu16.04LTS)

edit retag flag offensive close merge delete


How long have you left the listener running for to wait for a response? Discovery can take some time, although on a local machine I would expect it to success fairly quickly.

Geoff gravatar image Geoff  ( 2018-09-10 01:38:31 -0500 )edit

I waited for about ten seconds,but not try it more. After a change of my ufw, I could success quickly.

takijo gravatar image takijo  ( 2018-09-10 17:47:05 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-08-12 20:59:48 -0500

Geoff gravatar image

Make sure that you are allowing multicast traffic in the firewall. By default, the ufw firewall included in 16.04 blocks multicast traffic, even for loopback (i.e. on the same system). Here's an example of allowing multicast in ufw.

edit flag offensive delete link more



I can communicate with listener by the the way of above site.

I allow udp multicast in ufw.

sudo ufw allow in proto udp to
sudo ufw allow in proto udp from

Thank you for your help!

takijo gravatar image takijo  ( 2018-08-13 08:31:39 -0500 )edit

If you run into a similar problem you can try the new multicast verb to test if simple multicast functionality is working for you:

Dirk Thomas gravatar image Dirk Thomas  ( 2018-09-10 17:54:09 -0500 )edit

Also note, the same symptoms (i.e. ROS2 Talker cannot communicate with Listener) occur if the computer has no network configured. To test, try this: ros2 multicast receive in one terminal and ros2 multicast send in another terminal. If there are errors like load_entry_point … then plug your computer into a network and try again.

Tav_PG gravatar image Tav_PG  ( 2019-09-25 22:16:15 -0500 )edit

Is there someone else with ros2 multicast working, other nodes are not able to see each other? Even ros2 topic pub /chatter std_msgs/String "data: ping" in one terminal isn't noticed by ros2 topic list in an another terminal. Of cause both have ros2 galactic sourced.

codierknecht gravatar image codierknecht  ( 2021-08-23 15:23:18 -0500 )edit

@codierknecht, I also have that issue, what version are you running? did you ever find a fix?

twaddell gravatar image twaddell  ( 2021-09-27 23:38:40 -0500 )edit

@twaddell I did mange to solve the problem for running nodes on the same machine by exporting ROS_LOCALHOST_ONLY=1. However I currently don't have a second machine due to cross-compilation problems for a raspberry pi model 2b.

codierknecht gravatar image codierknecht  ( 2021-10-01 07:14:07 -0500 )edit

I have a similar problem. I am trying to connect a raspberry pi 3B+ to my pc with ROS2. I can connect to it just fine, my firewall is not active and multicast/ping between them works. However, topics listed on my pi do not show up on my pc and talker listener mode does not work either. (listener no response). ROS_ID is both 30. Please help me I do not know what else to do.

RickROS2 gravatar image RickROS2  ( 2023-01-12 07:10:17 -0500 )edit

I have a similar problem with ROS2 humble. I tried several things, including: sudo ufw allow in proto udp to sudo ufw allow in proto udp from "ros2 multicast receive" and "ros2 multicast send" communicated between two machines over wifi, but the talker and listener still didn't.

grhex gravatar image grhex  ( 2023-04-03 16:02:32 -0500 )edit

Question Tools



Asked: 2018-08-12 08:13:49 -0500

Seen: 6,009 times

Last updated: Sep 08 '18