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

If a service process dies in the middle of servicing a request, how does the client avoid waiting forever?

asked 2012-09-18 16:02:21 -0500

updated 2012-09-19 06:18:38 -0500

It appears that if a service's process dies in the middle of handling a request, the service call on the client side will hang forever.

Is there any way around this besides putting the service call in its own thread and killing the thread after a timeout?


edit retag flag offensive close merge delete


How long did you wait? I think the sockets should die at some point, maybe after 2 minutes or so. Does the service client not throw an exception in that case? (I believe in roslisp, it does :))

Lorenz gravatar image Lorenz  ( 2012-09-18 23:18:36 -0500 )edit

Wow. I just tested your code and it really seems like the service call blocks forever...

Lorenz gravatar image Lorenz  ( 2012-09-19 02:02:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-09-18 20:44:44 -0500

weiin gravatar image

updated 2012-09-19 15:24:29 -0500

Based on the client code attached in the ticket, I added the line:

if(!client.waitForExistence(ros::Duration(5.0))) continue; before the service call (line 21). This allows the client to carry on and make service calls once the server comes up again.

Retried the code again after Lorenz's comment. It seems this worked only when the server was killed at specific points in time (just before the service call I presume). Though I still don't understand why it worked previously when the "Failed to call service" line wasn't printed.

edit flag offensive delete link more



I don't think that solves the problem of blocking service calls in the client that never return because the server went down.

Lorenz gravatar image Lorenz  ( 2012-09-18 23:17:18 -0500 )edit

It is true that particular service call (when server dies) does not return (I do not get the message "Failed to call service add_two_ints"). But the client does continue to run its next loop until waitForExistence and until the server comes up again. ie the client does not hang

weiin gravatar image weiin  ( 2012-09-19 00:07:50 -0500 )edit

The client actually cannot continue with its loop since the service call is blocking. I still don't see how waitForExistence could help if the service call just does not return, which is apparently the case.

Lorenz gravatar image Lorenz  ( 2012-09-19 01:05:37 -0500 )edit

Question Tools



Asked: 2012-09-18 16:02:21 -0500

Seen: 1,524 times

Last updated: Sep 19 '12