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

rosjava - Subscriber java.net.ConnectException: localhost/127.0.0.1:37172 - Connection refused [closed]

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

eugen gravatar image

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

Hello,

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


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

NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(hostLocal, uri);          
nodeConfiguration.setMasterUri(uri);
nodeConfiguration.setNodeName("nodeName");  
nodeRunner.run(new 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 = "192.168.178.29"), i get an error:


E/UpdatePublisherRunnable(10630): java.lang.RuntimeException: java.net.ConnectException: localhost/127.0.0.1:37172 - Connection refused

by trying to debug your sourcecode and I have seen in 'MasterClien.java' 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
0

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

damonkohler gravatar image

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

edit flag offensive delete link more
0

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

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
0

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

damonkohler gravatar image

If you're running on the emulator, you'll need to use port forwarding. But, that probably won't work. See http://answers.ros.org/question/30018/rosjava-on-android-emulator

edit flag offensive delete link more
0

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

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 192.168.13.7 (ubuntu IP), and even stored it to ~/.bashrc to change it permanently. then ROS_MASTER_URI to http://192.168.13.7:11311

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

Question Tools

Stats

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

Seen: 2,219 times

Last updated: Mar 30 '12