Rosanswers logo

Currently I have two computers, one running a service 'TIME_SPAM' which endlessly sends UNIX timestamps to any subscribers. On a client PC, using the command 'ROS_MASTER_URI="hxxp://" rostopic echo TIMEPAM' (Note: Changed from a http link as my karma is insufficient to post links) only works if I have added a hostname entry which resolves to that PC in /etc/hosts (currently it's ' linaro-ubuntu-desktop'), if I comment the line out, the command no longer works, despite the fact that I'm passing it a direct IP address.

There are many obvious advantages to using Hostnames for lookups, but this becomes problematic if you do not own or control the network and are unable to setup static IP's and/or a DNS server..

Is there a reason for this, if not, where do I submit a bug report/feature request?

EDIT: The more I think about this problem, the more I consider it to be a bug - Consider this scenario:

I have a server with the IP and the hostname 'server', on the server I execute this script: http://paste2.org/p/2599990.

On a client, if I attempt to execute the command 'ROS_MASTER_URI="" rostopic echo TIMESPAM' it connects to the server, but does not display any data (this is different from an invalid host address, as it complains with 'could not connect to host').

Then, on the client, if I add an entry into /etc/hosts such that the hostname 'server' is bound to, a fresh execution of the command 'ROS_MASTER_URI="" rostopic echo TIMESPAM' will immediately work correctly.

This appears to be an issue with the client needing to know the hostname of the server, despite the fact I'm passing the IP address as the URI - and the behavior of the issue may lead somebody to assume that the problem is elsewhere in the system.

Originally posted by coldogga on ROS Answers with karma: 11 on 2012-12-11

Post score: 1


1 Answer 1


Rosanswers logo

The short answer is that you are not forced to use ROS_HOSTNAME and hostnames but you can also use IP addresses in ROS_MASTER_URI and the ROS_IP variable. If you have a dynamic IP address, you have to change ROS_IP whenever your IP changed and you will have to restart all your nodes.

And here the longer explanation of the why:

There are technical reasons for requiring either a hostname or an ip address.

Let's consider a simple example: computer A runs the core and subscribes to topic with node node_1. Computer B runs node_2 with a publisher for topic.

When the nodes are started up, they first register at the core (the ros::init call does that). To find the master, they use the ROS_MASTER_URI. For negotiating topic connections, each node provides an XMLRPC server. When registering at the master, nodes basically store the URI of this server. For that, the ROS_HOSTNAME and ROS_IP variables are used.

With the advertise call in node_2, it will communicate with the core again to register a publisher for topic.

The subscribe call in node_1 will also communicate with the core to find out which nodes are already publishing topic and the answer will be the address of node_2 that was used when it registered at the core. Note that if the publisher registers after the subscriber, the subscriber node is notified by the core using an XMLRPC call to node_1's local XMLRPC server. Finally, node_1 will directly connect to node_2 and establish the topic connection using the information about node_2's XMLRPC server stored in the core.

Originally posted by Lorenz with karma: 22731 on 2012-12-11

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by coldogga on 2012-12-13:
Please see edit above, your explanation is informative, but suggests EITHER a hostname OR ip address. Because of this, along with the above mentioning, I believe this is a bug and have raised it on trac https://code.ros.org/trac/ros/ticket/4071


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.