unresolved address when instantiating a service client on rosjava android
Hi,
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);
Thread.sleep(100);
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:
com.my.sample1rosapp 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(ConnectionTrackingHandler.java:81)
at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:533)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:157)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:102)
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:55)
at org.jboss.netty.channel.Channels.connect(Channels.java:642)
at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:205)
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:230)
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:183)
at org.ros.internal.transport.tcp.TcpClient.connect(TcpClient.java:101)
at org.ros.internal.transport.tcp.TcpClientManager.connect(TcpClientManager.java:69)
at org.ros.internal.node.service.DefaultServiceClient.connect(DefaultServiceClient.java:137)
at org.ros.internal.node.service.ServiceFactory.newClient(ServiceFactory.java:146)
at org.ros.internal.node.DefaultNode.newServiceClient(DefaultNode.java:365)
at org.ros.internal.node.DefaultNode.newServiceClient(DefaultNode.java:372)
at com.my.sample1rosapp.ExampleNode.onStart(ExampleNode.java:44)
at org.ros.internal.node.DefaultNode$5.run(DefaultNode.java:506)
at ...