"Could not determine the type for the passed topic" in ros2 topic echo

"Could not determine the type for the passed topic" in ros2 topic echo: publisher timing, the daemon, domain ID, custom messages, RMW and discovery range, measured

$ ros2 topic echo /x
WARNING: topic [/x] does not appear to be published yet
Could not determine the type for the passed topic

Short answer: ros2 topic echo without a type looks the type up once, about one second after it starts. If it finds no publisher by then, it prints this error and exits with code 1. It doesn't wait. When I passed the type myself, echo waited and printed the first message as soon as a publisher showed up:

ros2 topic echo /x std_msgs/msg/String

With the publisher starting 3 seconds after echo, the first message arrived at 3.82 s on Humble and 3.89 s on Jazzy and Lyrical. This worked with and without the daemon. If echo with an explicit type still prints nothing, the two processes can't discover each other. In my runs that meant a different ROS_DOMAIN_ID, ROS_LOCALHOST_ONLY or ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST across containers. The rest of this post goes through each cause with the exact output, the exit code and the time each command took.

Cause 7: discovery settings across containers — measured results table
At a glance: the main measured table from this article. Full details below.

Find your error

What you see Most likely cause (measured)
Could not determine the type for the passed topic after about 1 s, exit 1 No publisher yet, publisher in another domain or another discovery range, or the daemon hasn't seen it yet
Same error, but --no-daemon works The ros2 daemon missed the publisher (started just before, or the daemon started after it on Jazzy and Lyrical)
The message type 'tec_msgs/msg/Num' is invalid, exit 1 Custom message package not sourced in the echo shell
The passed message type is invalid, exit 1 Same, with the type passed on the command line
No output at all, echo keeps running Type passed explicitly, but no publisher is reachable
ros2 topic info: Unknown topic '/x', exit 1 No publisher seen
ros2 topic hz: only the WARNING line, keeps running No publisher yet. hz waits, unlike echo

What I ran

On 2026-10-30 I used the official ros:humble-ros-base, ros:jazzy-ros-base and ros:lyrical-ros-base images on a 2 vCPU Linux host, one distro after another. The publisher was always ros2 topic pub -r 2 /x std_msgs/msg/String "{data: hi}", so 2 messages per second. In each container I also installed rmw_cyclonedds_cpp next to the default Fast DDS and built a one-message package, tec_msgs/msg/Num. Causes 1 to 6 ran inside one container. Cause 7 used two containers on one Docker bridge network.

Each command ran under timeout with an 8 to 12 second limit. A script recorded each output line with the seconds since start, the exit code and the time to the first message. Exit 1 means echo gave up on its own. Exit 124 (Humble, Jazzy) or 137 (Lyrical) means it was still running when the timeout stopped it, which is what you want from echo. Before each case the script stopped all publishers and the daemon, unless the case was about the daemon.

Cause 1: the publisher isn't running yet

With no publisher, echo printed the warning and the error and exited with code 1. It made no difference whether I used the daemon:

Case Humble Jazzy Lyrical
echo /x, no publisher exit 1 after 1.00 s exit 1 after 1.15 s exit 1 after 1.12 s
echo --no-daemon /x, no publisher exit 1 after 0.97 s exit 1 after 1.05 s exit 1 after 1.07 s
echo /x, publisher starts 3 s later exit 1 after 1.03 s exit 1 after 1.07 s exit 1 after 1.08 s
echo --no-daemon /x, publisher starts 3 s later exit 1 after 0.97 s exit 1 after 1.06 s exit 1 after 1.22 s
echo --no-daemon /x, publisher started 0.5 s before first message 0.84 s first message 1.40 s first message 1.39 s

So echo doesn't wait for a publisher that starts later, even by a few seconds. If you start echo and the publisher at the same time, as a launch file or two terminals often do, echo can lose that race. Start echo after the publisher, or pass the type (cause 6).

The two other commands from the same package behave differently. ros2 topic info /x with no publisher printed Unknown topic '/x' and exited with 1 after about 1 s. ros2 topic hz /x printed the same WARNING line and then kept waiting. When the publisher started 3 s later, hz printed its first average rate: 2.000 at 5.86 s on Humble, 5.93 s on Jazzy and 5.00 s on Lyrical. hz doesn't print "Could not determine the type" here. It waits.

Cause 2: the daemon is behind

Without --no-daemon, echo asks the ros2 daemon which topics exist. The daemon is a background process that runs discovery all the time. I expected a stale daemon after changing environment variables in the same shell. That turned out to be the smaller problem. The daemon simply not having seen a new publisher yet caused more failures.

Changing ROS_DOMAIN_ID doesn't leave a stale daemon. After export ROS_DOMAIN_ID=7, ros2 daemon status said The daemon is not running, because each domain gets its own daemon. Echo started a new one and received data on all three distros.

Changing RMW_IMPLEMENTATION to rmw_cyclonedds_cpp while a Fast DDS daemon was running didn't break anything either. The old daemon listed the Cyclone publisher's /x, and echo received data on all three distros, before and after ros2 daemon stop.

Setting ROS_LOCALHOST_ONLY=1 after the daemon started broke echo on Humble: exit 1 after 0.34 s. In the same shell, ros2 daemon stop fixed it, and the next echo received its first message at 0.85 s. --no-daemon also worked. On Jazzy the old daemon still found the publisher. Lyrical ignores the variable (see Version notes).

A publisher that started just before echo failed on every distro when the daemon was already running. The publisher had started 0.5 s earlier, and echo exited with 1 after 0.34 s (Humble), 0.42 s (Jazzy) and 0.67 s (Lyrical). The same setup with --no-daemon received data on all three.

A daemon that starts after the publisher is flaky on Jazzy and Lyrical. I let the publisher run for 5 s, stopped the daemon and ran echo, which starts a new daemon. Then I ran echo a second time right away. I did this five times per distro:

Case (publisher running 5 s) Humble Jazzy Lyrical
First echo, daemon started by this call 5 of 5 received 2 of 5 received 2 of 5 received
Second echo, daemon already running 5 of 5 received 2 of 5 received 2 of 5 received
Daemon started 3 s before the publisher 3 of 3 received 3 of 3 received 3 of 3 received
ros2 topic info, daemon started by this call 3 of 3 found the type 3 of 3 found the type 3 of 3 found the type

The failures printed the usual two lines and exited with 1. On Jazzy and Lyrical, running echo a second time wasn't a reliable fix. What did work every time was --no-daemon, or a daemon that was already running before the publisher started. If you work in fresh containers, where every first ros2 command starts a new daemon, this is likely the cause. In my two-container runs on Jazzy and Lyrical, plain echo against a default publisher failed and --no-daemon worked.

ros2 daemon stop          # then retry; or skip the daemon entirely:
ros2 topic echo --no-daemon /x

Cause 3: a different ROS_DOMAIN_ID

With the publisher on domain 1 and echo on domain 2, echo printed the error and exited with 1 after 0.99 s (Humble), 1.09 s (Jazzy) and 1.08 s (Lyrical). Passing the type didn't help: ros2 topic echo /x std_msgs/msg/String printed nothing and was still running after 10 s on all three. That silence tells you discovery is the problem, not the type. On domain 1, echo worked on Humble and Jazzy. On Lyrical that control run failed the same way as cause 2, because it had just started a new daemon for domain 1. Check echo $ROS_DOMAIN_ID in both shells. An unset variable means domain 0.

Cause 4: the custom message package isn't sourced

The publisher shell had sourced /ws/install/setup.bash. The echo shell hadn't. This produces a different error, as long as echo can see the publisher:

$ ros2 topic echo /c
The message type 'tec_msgs/msg/Num' is invalid

$ ros2 topic echo /c tec_msgs/msg/Num
The passed message type is invalid

Both exited with code 1 on all three distros. ros2 topic hz /c printed the same is invalid line and exited with 1. ros2 topic info /c and ros2 topic list -t worked and showed tec_msgs/msg/Num, because they only need the type's name, not its definition. After sourcing the workspace, echo printed num: 1 at 1.03 s (Humble), 1.22 s (Jazzy) and 1.59 s (Lyrical).

There's one trap on Jazzy and Lyrical. When echo had to start a new daemon, the unsourced shell printed Could not determine the type for the passed topic instead, because the cause 2 problem hit first. With --no-daemon or a daemon already running, the same shell gave the is invalid message. If ros2 topic list -t shows a type from your own package, source that workspace before you look anywhere else.

Cause 5: different RMW implementations

I ran each pairing with --no-daemon to keep the daemon out of it. A Cyclone DDS publisher with a Fast DDS echo worked on the first try on every distro. A Fast DDS publisher with a Cyclone DDS echo failed on the first try on all three: exit 1 after 0.87 s (Humble), 0.95 s (Jazzy) and 0.96 s (Lyrical). An identical second run right after it received data at 0.83 s, 0.91 s and 0.91 s. With the type passed, Cyclone echo received from the Fast DDS publisher on the first try, at 1.46 s, 1.94 s and 1.68 s. ros2 topic list --no-daemon --spin-time 5 on the Cyclone side listed /x.

So the two implementations did talk to each other for std_msgs/msg/String. The only failure was the first type lookup in one direction. I didn't find out why. Passing the type avoids it, and so does using the same RMW_IMPLEMENTATION on both sides, which also worked in my control run.

Cause 6: passing the type explicitly

With the type on the command line, echo doesn't need to look it up, so it doesn't exit. It creates the subscription and waits:

Case Humble Jazzy Lyrical
echo /x std_msgs/msg/String, publisher 3 s later first message 3.82 s 3.89 s 3.89 s
Same with --no-daemon 3.82 s 3.90 s 3.89 s
Type passed, no publisher ever no output, still running at 8 s same same

This is the fix to use in scripts and launch-time debugging. The cost is that a wrong setup is silent. You get no output instead of an error, so pair it with ros2 topic info -v /x from the same shell if nothing appears.

Cause 7: discovery settings across containers

Here the publisher and echo ran in two containers on the same Docker bridge network. Every result below is from --no-daemon, to keep cause 2 out of it:

Publisher env Echo env Humble Jazzy Lyrical
default default received, 0.84 s received, 1.22 s received, 1.01 s
ROS_LOCALHOST_ONLY=1 default error, exit 1 error, exit 1 received, 1.48 s
ROS_LOCALHOST_ONLY=1 ROS_LOCALHOST_ONLY=1 error, exit 1 error, exit 1 received, 0.99 s
ROS_LOCALHOST_ONLY=1 default, type passed no output, still running no output, still running received, 1.04 s
ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST default received, 0.84 s error, exit 1 error, exit 1
default ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST received, 0.85 s error, exit 1 error, exit 1
SUBNET SUBNET received, 0.84 s received, 1.09 s received, 0.98 s

Localhost-only on either side blocks discovery between containers, even when both sides set it. Each container has its own loopback, so "localhost" isn't shared. The error exits came after about 1 s, as in cause 1. Humble doesn't read ROS_AUTOMATIC_DISCOVERY_RANGE, and Lyrical doesn't read ROS_LOCALHOST_ONLY, so the same environment file gives different results depending on the distro. For containers on one network, unset both or use SUBNET. I covered the range values in more detail in nodes that can't see each other and ROS_AUTOMATIC_DISCOVERY_RANGE.

For what ROS_LOCALHOST_ONLY and ROS_AUTOMATIC_DISCOVERY_RANGE do to traffic on one machine, see whether ROS 2 traffic leaves the machine.

If the type is found but echo then prints nothing between containers started with --net=host, the cause I measured was Fast DDS shared memory: topic list works but topic echo prints nothing in Docker.

Quick decision table

Check If yes
Does ros2 topic echo --no-daemon /x work, but plain echo doesn't? Cause 2. Use --no-daemon, or run ros2 daemon stop and retry
Did the publisher start after echo, or at the same time? Cause 1. Pass the type, or start echo later
Does the error say is invalid? Cause 4. Source the workspace with the message package
Does echo with the type print nothing? Causes 3 or 7. Compare ROS_DOMAIN_ID, ROS_LOCALHOST_ONLY, ROS_AUTOMATIC_DISCOVERY_RANGE
Are the two sides on different RMW_IMPLEMENTATION values? Cause 5. Retry, pass the type, or use the same RMW

Version notes

The error text, the WARNING line and exit code 1 were identical on Humble (ros2cli 0.18.20), Jazzy (0.32.13) and Lyrical (0.40.9). With no publisher in the same container, echo gave up after 0.97 to 1.22 s on all three. The differences:

  • A daemon started after the publisher missed it in 3 of 5 tries on Jazzy and Lyrical and never on Humble.
  • Jazzy honors ROS_LOCALHOST_ONLY=1 and prints ROS_LOCALHOST_ONLY is deprecated but still honored if it is enabled. Use ROS_AUTOMATIC_DISCOVERY_RANGE and ROS_STATIC_PEERS instead. Lyrical printed nothing and ignored it.
  • Humble ignored ROS_AUTOMATIC_DISCOVERY_RANGE.
  • When the timeout stopped a running echo, the exit code was 124 on Humble and Jazzy and 137 on Lyrical.

Not tested

Real multi-machine networks, Wi-Fi, ROS_STATIC_PEERS, Fast DDS discovery server, Zenoh (rmw_zenoh), Connext, CYCLONEDDS_URI or Fast DDS XML profiles, message types other than std_msgs/msg/String across RMWs, services and actions, ros2 topic echo --spin-time, and Foxy, Iron, Kilted and Rolling.

FAQ

Why does ros2 topic echo say "Could not determine the type for the passed topic"?

It found no publisher for the topic within about one second, so it couldn't look up the type, and it exited with code 1. In my runs the publisher was either not running yet, on another domain or discovery range, or not yet seen by the ros2 daemon.

Does ros2 topic echo wait for the publisher?

Not without a type. With a publisher starting 3 s later it exited after about 1 s on Humble, Jazzy and Lyrical. With the type passed, as in ros2 topic echo /x std_msgs/msg/String, it waited and printed the first message at 3.82 to 3.90 s.

Does ros2 daemon stop fix it?

Sometimes. It fixed the case where ROS_LOCALHOST_ONLY was set after the daemon started on Humble. On Jazzy and Lyrical a freshly started daemon missed a running publisher in 3 of 5 tries, so --no-daemon was more reliable than restarting the daemon.

Why does echo say the message type is invalid?

The echo shell hasn't sourced the workspace that holds the message package. echo printed The message type 'tec_msgs/msg/Num' is invalid, while ros2 topic list -t still showed the type. Source install/setup.bash of that workspace in the echo shell.

Can ros2 topic echo use Cyclone DDS while the publisher uses Fast DDS?

Yes, data flowed both ways in my runs. A Cyclone echo against a Fast DDS publisher failed its first type lookup on all three distros and worked on the next try or with the type passed.

Measured on 2026-10-30 with ros:humble-ros-base (sha256:d9bcf2e6f72d..., ros2cli 0.18.20, rmw_fastrtps_cpp 6.2.10 with Fast DDS 2.6.12, rmw_cyclonedds_cpp 1.3.5 with Cyclone DDS 0.10.5), ros:jazzy-ros-base (sha256:8eed0a4669bb..., ros2cli 0.32.13, rmw_fastrtps_cpp 8.4.4 with Fast DDS 2.14.7, rmw_cyclonedds_cpp 2.2.4 with Cyclone DDS 0.10.5) and ros:lyrical-ros-base (sha256:3224ee150cb0..., ros2cli 0.40.9, rmw_fastrtps_cpp 9.4.10 with Fast DDS 3.6.2, rmw_cyclonedds_cpp 4.1.5 with Cyclone DDS 11.0.1). The default RMW was Fast DDS on all three. Full digests are in digests.txt.

Script and raw output: evidence folder. Questions this answers: ros2 topic echo chatter: topic does not appear to be published yet, Could not determine the type for the passed topic, Could not determine the type for the passed topic, ros2 topic can only echo certain topics (multiple machine), ros2 topic commands can't always determine the type, Dockerized approach, topics not showing locally.