Rosanswers logo

I am having trouble with actionlib.SimpleActionClient wait_for_server timing out when the client and server are on different systems and I could use help understanding why. In this case, roscore and the action server is running on a Raspberry Pi and the client is running on an Ubuntu VM. Both are running Indigo. I have a simple example that runs fine when the client and server run on the same computer (the Raspberry Pi). However when I run roscore and the action server on the Raspberry Pi and I run these commands on the Ubuntu client side:

  • rosnode list correctly lists the server node
  • rostopic list correctly lists the topics
  • rosnode ping ping_action_server shows repeated successful pings of about 20 msecs

However, when I run the following client code it fails to connect...

import sys
import rospy
import actionlib

from inmoov.msg import PingAction, PingGoal, PingResult

def onShutdown():
    rospy.loginfo("Shutting down")

    rospy.init_node('ping_client', log_level=rospy.DEBUG)
    client = actionlib.SimpleActionClient('ping', PingAction)
    rospy.loginfo("Waiting for ping action server...")
    finished = client.wait_for_server(timeout = rospy.Duration(10.0))
    if(finished is False): 
        rospy.logerr("Ping action server timed out")
        rospy.loginfo("Ping action server found")
    print("An exception was encountered")
    e = sys.exc_info()[0]
    print str(e)

The output is:

[DEBUG] [WallTime: 1473631183.986657] init_node, name[/ping_client], pid[7947]
[DEBUG] [WallTime: 1473631183.987061] binding to 0
[DEBUG] [WallTime: 1473631183.987256] bound to 35061
[DEBUG] [WallTime: 1473631183.987703] ... service URL is rosrpc://raspberrypi:35061
[DEBUG] [WallTime: 1473631183.987884] [/ping_client/get_loggers]: new Service instance
[DEBUG] [WallTime: 1473631184.003141] ... service URL is rosrpc://raspberrypi:35061
[DEBUG] [WallTime: 1473631184.003397] [/ping_client/set_logger_level]: new Service instance
[INFO] [WallTime: 1473631184.130352] Waiting for ping action server...
[DEBUG] [WallTime: 1473631184.131371] connecting to raspberrypi 52197
[DEBUG] [WallTime: 1473631184.131768] connecting to raspberrypi 52197
[DEBUG] [WallTime: 1473631184.152471] connecting to raspberrypi 52197
[ERROR] [WallTime: 1473631194.139802] Ping action server timed out
[INFO] [WallTime: 1473631194.140166] Shutting down
[DEBUG] [WallTime: 1473631194.192350] connecting to raspberrypi 52197
[DEBUG] [WallTime: 1473631194.193241] connecting to raspberrypi 52197

Any ideas would be appreciated. If it matters, I have a ROS publisher that runs on the Ubuntu VM and a ROS Subscriber on the Raspberry Pi that successfully receives the published messages. The Raspberry Pi has a static IP and the Ubuntu VM has an entry in /etc/hosts to map the static IP to the host name "raspberrypi".

Here are the Ubuntu environment settings:

mike@badmonkey:~$ printenv | grep ROS

Originally posted by anonymous27962 on ROS Answers with karma: 76 on 2016-09-11

Post score: 0

Original comments

Comment by ahendrix on 2016-09-11:
Your hostname is badmonkey but your ROS_HOSTNAME is raspberrypi. Can you ping a node that is running on your Ubuntu machine from your raspberry pi?

Comment by anonymous27962 on 2016-09-12:
No, rosnode list includes the node, but I get this...

pi@raspberrypi:~ $ rosnode ping leap_motion_publisher
rosnode: node is [/leap_motion_publisher]
pinging /leap_motion_publisher with a timeout of 3.0s
ERROR: connection refused to [http://raspberrypi:45057/]

Comment by ahendrix on 2016-09-12:
Your hostname is badmonkey but your ROS_HOSTNAME is raspberrypi, so any nodes running on your Ubuntu machine are advertising the wrong host name.


1 Answer 1


Rosanswers logo

As @ahendrix pointed out in the question comments, I was confused about ROS_HOSTNAME. I had assumed that was the hostname of the node running roscore. When I changed the ROS_HOSTNAME to properly reflect the hostname of the Ubuntu VM to be badmonkey instead of raspberrypi, the problem was resolved.

Thank you for your help!

Originally posted by anonymous27962 with karma: 76 on 2016-09-13

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.