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

When sending messages through rostopic, should both rosnodes need on?

asked 2016-11-03 21:48:51 -0500

Hi All:

Here is one question about the "rostopic". Can client rosnode send message to the topic when server rosnode is off? or vice versa. The topic concept is also be used in MQTT protocol. In their MQTT website description, the action of sending messages from one node to another through topic does not need to concern about the received one condition(that means received one can be on or off state) due to the waste of long-term internet connections and the occupitation of the internet bandwidth ?

edit retag flag offensive close merge delete



@JoshMarino why not post this as an answer? :-)

mgruhler gravatar image mgruhler  ( 2016-11-04 02:09:22 -0500 )edit

"A publisher sends the message regardless if anyone listens to it or not." How is this possible if messages are transported via TCP? Or do you just mean that the .publish(msg) does not block if there is no listener?

NEngelhard gravatar image NEngelhard  ( 2016-11-04 04:44:05 -0500 )edit

publish(..) never blocks.

And whether TCP is used or not doesn't matter: if there are no subscribers, there are no connections between nodes, so the middleware will simply discard the msg passed to it by the various .publish(..) methods.

Only nodes exchange msgs, the master is not involved.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-05 07:19:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-11-03 22:14:03 -0500

JoshMarino gravatar image

A publisher sends the message regardless if anyone listens to it or not.

A subscriber will not enter its callback function if no message is received. The subscriber can still be running though and doing nothing if no message is ever received.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-11-03 21:48:51 -0500

Seen: 551 times

Last updated: Nov 03 '16