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

unresolved address when instantiating a service client on rosjava android

asked 2016-09-01 11:00:53 -0500

al gravatar image

updated 2016-09-01 12:22:11 -0500

gvdhoorn gravatar image


I have roscore and turtlesim_node on an ubuntu running in virtualbox under windows10, and a rosjava android app. The android app is starting correctly, finding the master. I can see the ros graph correctly from the linux computer.

Then I have added in the rosjava-android node the creation of a serviceclient to change the request the turtlesim_node to change the position of the turtle by invoking the service /turtle1/teleport_absolute. On the linux computer, the roscore and the turtlesim_node are running up.

In my android node, the code is like this:

public void onStart(final ConnectedNode connectedNode) {
        try {
            Log.d("BLAH", "ServiceCLient... creating serviceclient!");
            serviceClient = connectedNode.newServiceClient("/turtle1/teleport_absolute", TeleportAbsolute._TYPE);
            Log.d("BLAH", "ServiceCLient CREATED!"); // this is never reached
        } catch (ServiceNotFoundException e) {
            Log.d("BLAH", "ServiceCLient FAILED!"); // the exception thrown is not of this kind...
            throw new RosRuntimeException(e);
        catch (Exception ex){
            Log.d("BLAH", "ServiceCLient Definitively FAILED!"); // so this will catch the exception to avoid crashing the app

it fails when creating the serviceclient. The stacktrace looks like the one below.

Apparently, the android node cannot reach the master when creating a serviceclient. But a call to getRosHostname() and getMasterUri() in the init() method of my rosactivity confirms that the IPs are correct, and I can see the graph and the list of nodes and services on the linux computer with no problem.

Moreover, Ping commands in both computers (linux and android) are successful when IPs are used. I cannot resolve by name.

I wonder what I am missing, and whether rosjava is taking a name instead of a ip when creating a serviceclient, causing this issue due to using a virtualized linux.

Any help will be very useful.

Stacktrace: W/DefaultChannelPipeline: An exception was thrown by a user handler while handling an exception event ([id: 0x14cf6630] EXCEPTION: java.nio.channels.UnresolvedAddressException)                                                                                                org.ros.exception.RosRuntimeException: java.nio.channels.UnresolvedAddressException
at org.ros.internal.transport.ConnectionTrackingHandler.exceptionCaught(
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(
at org.jboss.netty.bootstrap.ClientBootstrap.connect(
at org.jboss.netty.bootstrap.ClientBootstrap.connect(
at org.ros.internal.transport.tcp.TcpClient.connect(
at org.ros.internal.transport.tcp.TcpClientManager.connect(
at org.ros.internal.node.service.DefaultServiceClient.connect(
at org.ros.internal.node.service.ServiceFactory.newClient(
at org.ros.internal.node.DefaultNode.newServiceClient(
at org.ros.internal.node.DefaultNode.newServiceClient(
at org.ros.internal.node.DefaultNode$
at ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-09-02 09:34:06 -0500

al gravatar image

I tested a few more things. I created a rosjava node running directly on windows/jvm. I got the same issue, like in the rosjava node running in android.

The serviceclient is using the name of the host where the ros master is running instead of the ip. So the temporal solution is to edit the hosts file of the system, so that it can resolve it by name.

edit flag offensive delete link more


I have also tested with the ros master and the turtlesim running in ubuntu natively (without virtualbox). I needed to set the hosts file in windows too. So the issue is more with the network configuration in all the computing nodes so that they can find each other by name. any suggestion to config?

al gravatar image al  ( 2016-09-02 11:21:11 -0500 )edit

Al, If you find this issue in the rosjava source code, you can update the source to use IP instead of host and then rebuild the source. Here are instructions on rebuilding from source.

dambrosio gravatar image dambrosio  ( 2017-02-16 10:03:44 -0500 )edit

thanks for the instructions. I will try to find time for that.

al gravatar image al  ( 2017-02-16 11:25:49 -0500 )edit

Hi @al - did you have any success with that - I have the same problem.

Will Chamberlain gravatar image Will Chamberlain  ( 2017-02-19 21:54:18 -0500 )edit

Easier to set the environment variable ROS_IP in the PC

Read the following:

al gravatar image al  ( 2017-04-26 11:20:58 -0500 )edit

Question Tools

1 follower


Asked: 2016-09-01 11:00:53 -0500

Seen: 979 times

Last updated: Sep 02 '16