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

rosjava - Subscriber localhost/ - Connection refused [closed]

asked 2012-01-01 05:26:19 -0500

eugen gravatar image

updated 2012-01-01 05:27:59 -0500


I am trying to start a ros Subscriber an android device. My sourcecode look like:

String hostLocal = InetAddressFactory.newNonLoopback().getHostAddress();
String hostMaster = ((EditText)findViewById(;
Integer port = Integer.parseInt(((EditText)findViewById(;
URI uri = URI.create("http://" + hostMaster + ":" + port);              

NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(hostLocal, uri);          
nodeConfiguration.setNodeName("nodeName"); Listener(), nodeConfiguration);

If i start the ros-master local on my android device - it works fine. But if the master is running an my PC (for example: hostMaster = ""), i get an error:

E/UpdatePublisherRunnable(10630): java.lang.RuntimeException: localhost/ - Connection refused

by trying to debug your sourcecode and I have seen in '' file a following function:

return Response.fromListChecked(node.registerSubscriber(slave.getName().toString(), subscriber
        .getTopicName().toString(), subscriber.getTopicMessageType(), slave.getUri()
        .toString()), new UriListResultFactory());

Befor I had called a funciton, I had follwing screen:

image description

But after calling of function I have seen:

image description

You can see, that after calling a funciton it is the uri of client not the same. Is this issue known or not. What can I do?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by damonkohler
close date 2012-03-30 04:20:11

4 Answers

Sort by ยป oldest newest most voted

answered 2012-01-05 00:59:43 -0500

damonkohler gravatar image

It looks to me like you have not set ROS_IP on your host PC.

edit flag offensive delete link more

answered 2012-03-28 02:38:50 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I followed the answer but it didn't solve my problem here. I have the same error. and I set my ROS_IP on PC to (ubuntu IP), and even stored it to ~/.bashrc to change it permanently. then ROS_MASTER_URI to

started roscore on pc, and run listener on android using a AVD. Then this error occured and roswtf reported that Could not contact the following nodes: ...; the following nodes should be connected but aren't...

edit flag offensive delete link more

answered 2012-03-30 04:19:52 -0500

damonkohler gravatar image

If you're running on the emulator, you'll need to use port forwarding. But, that probably won't work. See

edit flag offensive delete link more

answered 2012-03-28 12:16:02 -0500

kurmis gravatar image

Are you behind a router (or any NAT device)? if that is the case you will need to configure it to pass needed ports directly to your computer.

edit flag offensive delete link more

Question Tools


Asked: 2012-01-01 05:26:19 -0500

Seen: 2,182 times

Last updated: Mar 30 '12