Ask Your Question

Using rosservice across multiple machines [closed]

asked 2011-08-31 03:54:32 -0600

DimitriProsser gravatar image

updated 2012-02-27 07:34:35 -0600

kwc gravatar image

I am attempting to distribute my graph across multiple machines, M1 and M2. The IP of M1 is and the IP of M2 is

In the /etc/hosts file on M1, I have set:    machine2

And in the /etc/hosts file on M2, I have:    machine1

I am able to ping machine1 from machine2 and vice versa.

So then, I set up my launch file to use multiple machines with the following .machine file:

   <machine name="M1" address="machine1" ros-root="$(env ROS_ROOT)" ros-package-path="$(env ROS_PACKAGE_PATH)" user="m1user" default="true"></machine>
   <machine name="M2" address="machine2" ros-root="$(env ROS_ROOT)" ros-package-path="$(env ROS_PACKAGE_PATH)" user="m2user">
   <env name="ROS_MASTER_URI" value="http://machine1:11311" />

When I launch, everything connects fine, all of the nodes launch correctly, and I am able to do 'rostopic list' and 'rosservice list' to see all topics and services. Additionally, I am able to 'rostopic echo' any topic that is running in the graph.

The problem that I am having is that I am only able to call a service from a node that is running on the master machine, i.e. M1. For example, a service named "enable_teleop" is running in my robot_teleop node on the master machine, and I can call this service from either machine. However, if I try to call a service that is from a node on the second machine using either machine, I receive the following error:

> rosservice call /reset_odometry
> ERROR: Unable to communicate with service [/reset_odometry], address [rosrpc://machine2:56068]

I have tried setting the ROS_IP and/or ROS_HOSTNAME environment variables of both machines in every combination that I can think of, and still no luck. So my question is, how do I get around this problem? Does ROS require that all services be on the same machine as the roscore?


The output of 'rosservice info /reset_odometry' is as follows:

Node: /locator
URI: rosrpc://machine2:42244
ERROR: Unable to communicate with service [/reset_odometry], address [rosrpc://machine2:42244]

The output of roswtf is:

* service [/reset_odometry] appears to be malfunctioning: Unable to communicate with service [/reset_odometry], address [rosrpc://machine2:42244]

~ Brian

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by kwc
close date 2012-02-29 07:46:07


Did you ever figure this out? Out of curiosity, are your usernames the same on both machines? Also is passwordless ssh set up both ways?
Ibrahim gravatar imageIbrahim ( 2012-01-11 20:06:35 -0600 )edit
Yes and yes.
DimitriProsser gravatar imageDimitriProsser ( 2012-01-12 00:51:47 -0600 )edit
Hmm, so you didn't figure out what the problem was, or did you? I was having similar problems but I think it was partly because I had different usernames on different machines, or at least making a new account with the same username fixed some problems for me.
Ibrahim gravatar imageIbrahim ( 2012-01-12 12:24:02 -0600 )edit

Hey, 5 years later and now I have the same problem... Did you (or anyone else) find a solution in the meantime?

Felix Widmaier gravatar imageFelix Widmaier ( 2017-03-07 10:25:57 -0600 )edit

Unable to get this working, I have setup ros ip and master uri, I am able to get rospy_tutorials listener and talker working across the two computers. I can list the services also but not call them.

rudasi gravatar imagerudasi ( 2017-04-16 21:25:57 -0600 )edit

4 Answers

Sort by ยป oldest newest most voted

answered 2012-01-30 03:44:18 -0600

Running ros across multiple machines -whether you call a service or not- is actually not a big problem thanks to the rosmaster.

What we did in our lab is as follows:

on the central/host/master computer:

export ROS_MASTER_URI=http://master_machine_name:11311
export ROS_IP=master_machine_ip

on the client computer(s):

export ROS_MASTER_URI=http://master_machine_ip:11311
export ROS_IP=client_machine_ip

You may also need to add master_machine_ip master_machine_name mapping to /etc/hosts file on the client machines so that they can ping master_machine_name.

edit flag offensive delete link more

answered 2011-10-13 16:10:32 -0600

I'm experiencing exactly the same issue. The two machines seem to be able to communicate just fine (rostopic list/echo works fine), and the master is able to call services that are running on itself. However, an identical service call from a different machine to the master results in the error that you posted.

Have you been able to resolve the issue?

edit flag offensive delete link more


I have not been able to fix this issue yet
DimitriProsser gravatar imageDimitriProsser ( 2011-10-14 03:10:07 -0600 )edit

answered 2011-08-31 04:59:46 -0600

Markus Achtelik gravatar image

you might have to add both hostname/ip cominations to each /etc/hosts file, i.e.    machine1    machine2

The problem could be that machine1 refers to / in machine1's hosts file. Local communication works, but when roscore tries to resolve the address when negotiating a connection between machine1 and machine2, it would still report ...

Hope that helps! Markus

edit flag offensive delete link more


Unfortunately, that didn't help. I get the same errors.
DimitriProsser gravatar imageDimitriProsser ( 2011-08-31 05:45:23 -0600 )edit

answered 2011-08-31 04:26:23 -0600

Lorenz gravatar image

Distributing services across different machines shouldn't be a problem. What's the output of rosservice info /reset_odometry and roswtf? Does it maybe give any valuable information?

edit flag offensive delete link more


I've placed the results in an edit to the original question
DimitriProsser gravatar imageDimitriProsser ( 2011-08-31 04:34:41 -0600 )edit
Which node is actually providing this service? Are you sure it didn't die with something like a segfault? In that cause, roswtf should give something like: ERROR Could not contact the following nodes: ...
Lorenz gravatar imageLorenz ( 2011-08-31 04:43:07 -0600 )edit
Which node is actually providing this service? Are you sure it didn't die with something like a segfault? In that cause, roswtf should give something like:
Lorenz gravatar imageLorenz ( 2011-08-31 04:43:08 -0600 )edit
I was just using that node and service as an example. I have about 6 nodes and 12 services all doing the same thing. And I know they're alived because I can echo some topics that they publish to.
DimitriProsser gravatar imageDimitriProsser ( 2011-08-31 05:01:07 -0600 )edit

Question Tools

1 follower


Asked: 2011-08-31 03:54:32 -0600

Seen: 2,233 times

Last updated: Jan 30 '12