Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

rosjava nodes default to host=127.0.0.1 if you don't have ROS_IP set #259

Open
amaldo opened this issue Nov 20, 2017 · 1 comment
Open

Comments

@amaldo
Copy link

amaldo commented Nov 20, 2017

Hi!

We have some code in our laboratory called json_prolog that uses rosjava by extending the AbstractNodeMain class. The class is here:

https://github.com/knowrob/knowrob/blob/master/json_prolog/json_prolog/src/main/java/org/knowrob/json_prolog/JSONPrologNode.java

After some strange communication problems, we found out that in the following line, the default IP that gets reported to the ROS core is always 127.0.0.1, instead of the hostname as it is normal in the ros world. We tracked the error to the following line:

String host = InetAddressFactory.newLoopback().getHostAddress();

String host = InetAddressFactory.newLoopback().getHostAddress();

That sets 127.0.0.1 as the default, which can get later overwritten by setting the ROS_IP environmental variable.

I suspect that it would be better to change that line to the following to follow the normal roscpp behaviour:

String host = InetAddressFactory.newNonLoopback().getHostName();

Greetings!

@jubeira
Copy link

jubeira commented Nov 20, 2017

Hi @amaldo,
Thanks for your comments. May I ask how you are executing the nodes? The IP address used by the node to advertise itself to the ROS master is set in the NodeConfiguration object, which is used when the node is executed. It's not related with the code of the node itself.

If I understand correctly, what you are saying is that when you use the RosRun class from the command line, the node is executed by default using the loopback address and not the hostname. Is that the case?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants