Field guide
ROS 2 Service Timeouts: Retry Without Duplicating Work
Separate ROS 2 client timeouts from server outcomes. Review operation IDs, retry reconciliation, restart gaps, and duplicate effects with a runnable model and worksheet.
The short answer
A ROS 2 service timeout means the client did not obtain a response within its waiting policy. It does not prove that the server did nothing. Before retrying a command with side effects, reconcile the original operation, preserve its application identity, and establish whether repeating it is permitted.
The reviewed Jazzy rclpy client makes this boundary concrete. call() sends an asynchronous request, waits on an event, and removes the pending request if that wait expires. remove_pending_request() removes the client-side entry that would receive the response. Neither path sends a server cancellation request. A dashboard must not turn that local cleanup into a green light to repeat a physical operation.
This guide provides a retry decision matrix, a runnable lost-response model, and a handoff worksheet. We reviewed first-party Jazzy documentation and source on November 12, 2026. We executed only the standalone Python model below, not ROS nodes, network fault injection, or robot hardware. The retry contract and acceptance checks are our engineering review framework, not guarantees supplied by ROS or a certified safety procedure.
Separate three identities before adding retries
The Jazzy client implementation associates a pending future with a sequence number returned when it sends a request. That is response tracking for a call. Our proposed integration contract distinguishes it from two other identities:
| Identity | Purpose | Retry rule to define |
|---|---|---|
| Transport request identity | Match a particular service call with its response | Retain it for diagnostics; do not assume it deduplicates business work |
| Application operation ID | Identify the intended unit of work across attempts | Reuse the same ID when reconciling or retrying that same operation |
| Target and command meaning | Identify the resource and exact requested effect | Bind the operation ID to a canonical command and reject conflicting reuse |
For an invented fixture command, operation_id=job-42-clamp and target=fixture-A describe a different contract from simply calling toggle_clamp again. Setting a declared state may be easier to reconcile than toggling it, but even a repeated set command can retrigger device behavior. Require the device owner’s evidence, not an assumption based on the verb.
An operation ID is an application-interface proposal. Existing service definitions do not acquire that field because a client records it in a log. Both request handling and result lookup must support the agreed identity, or a gateway must own that mapping. Authorization still applies to every lookup and retry; knowing an ID must not grant control of another resource.
For broader communication validity, see our network QoS and stale-data guide. That problem is distinct from deciding whether a timed-out command has already taken effect.
Diagnose the wait before repeating the work
The official Jazzy client guide recommends asynchronous Python service clients and describes deadlocks from synchronous calls, including blocking a callback whose thread must also process the response. A missing result is therefore not automatically a network outage or a slow robot.
Check whether the executor can process the response, whether the future remains tracked, and what the server recorded. Moving to call_async() changes how the client waits. It does not make the command idempotent, establish physical completion, or resolve an already ambiguous outcome.
Use the following proposed decision matrix. Every row needs application-specific evidence and authority, not just a timeout threshold.
| Observation | What remains unknown | Proposed next step |
|---|---|---|
| Service not ready before sending | Whether a later server will be ready | Wait or fail admission without claiming a command was issued |
| Request sent, no response by client deadline | Reception, execution, and completion | Mark unresolved; reconcile the original operation before another effect |
| Server reports operation still running | Final result and physical state | Observe the same operation; do not create a replacement identity |
| Same ID has a recorded completed result | Whether physical evidence meets the task contract | Return that result without repeating the effect, then verify required state |
| Same ID arrives with different command content | Whether the caller has confused operations | Reject the conflict; do not silently reuse or overwrite the result |
| Server restarted and operation evidence is missing | Whether work happened before the restart | Require reconciliation or an authorized recovery procedure, not a blind retry |
Readiness is only a pre-send observation. The client source describes wait_for_service() as waiting for a service server to become ready. It is not a reservation or a result for the next command.
Reproduce the lost-response problem without ROS
This synthetic model represents a server completing an invented effect, remembering its result, and then losing the response before the client sees it. It compares an unprotected retry with reuse of the same operation ID. There is one sequential caller, no concurrency, no restart, and no hardware.
class ToyServer:
def __init__(self, remember):
self.remember = remember
self.results = {}
self.effects = 0
def request(self, operation_id, command, lose_response=False):
if self.remember and operation_id in self.results:
previous_command, result = self.results[operation_id]
if previous_command != command:
raise ValueError("operation ID conflict")
else:
self.effects += 1
result = {"effect_number": self.effects}
if self.remember:
self.results[operation_id] = (command, result)
if lose_response:
raise TimeoutError("response not observed by client")
return result
for remember in (False, True):
server = ToyServer(remember)
try:
server.request("job-42", "fixture-A:set-closed", lose_response=True)
except TimeoutError:
pass
reply = server.request("job-42", "fixture-A:set-closed")
assert server.effects == (1 if remember else 2)
print("remember:", remember, "effects:", server.effects, "reply:", reply)
try:
server.request("job-42", "fixture-A:set-open")
except ValueError:
print("conflicting reuse: rejected")
else:
raise AssertionError("conflicting operation ID was accepted")
Our execution produced:
remember: False effects: 2 reply: {'effect_number': 2}
remember: True effects: 1 reply: {'effect_number': 1}
conflicting reuse: rejected
This is not an exactly-once implementation. The dictionary is volatile. A crash after the effect but before recording its result leaves an ambiguity that this example does not solve. Concurrent handlers could also both execute before a result exists. A production contract needs atomic admission of an operation identity, an explicit in-progress state, durable recovery evidence, and a defined retention period. Merely writing a result after moving a mechanism does not make those two events atomic.
Where the external device cannot participate in a transaction, define how its state or operation history can be reconciled. If that evidence is insufficient, preserve an unresolved outcome and require the agreed recovery authority. Do not advertise exactly-once physical behavior on the strength of this software model.
Review the crash window and retention policy
Our proposed design review asks four questions that a happy-path retry misses:
- What if a duplicate arrives during execution? Define whether it gets an in-progress response, observes the original result, or is refused. It must not silently start a second effect.
- What survives a restart? Preserve enough operation identity, command content, status, and device evidence to distinguish completed, not started, and unresolved work. Missing evidence is not proof of nonexecution.
- What happens after deduplication records expire? Agree how long retries remain valid. Reject or reconcile an expired identity rather than treating it as new by accident.
- Who may retry or override? Bind permissions, resource ownership, and the recovery decision to the operation. An operator override should be recorded as a deliberate recovery action, not hidden as automatic retry success.
These are application requirements, not features demonstrated by the pinned rclpy client. Keep each result’s scope explicit: server admission, server completion, device acknowledgement, and verified physical condition are different evidence.
The Jazzy service concepts say services should return quickly and should not be used for long-running processes that may need preemption. Consider an action for that interface need. Actions still require an application retry policy; their cancellation states are not a universal physical stop guarantee.
A retry acceptance worksheet
Use this worksheet with the interface owner before enabling automatic retries. Entries remain NOT TESTED until the receiving team supplies observations. Perform any fault injection in an isolated, authorized environment before considering a physical system.
Service name, interface version, ROS distribution, implementation revision:
Target resource and authorized command:
Application operation ID field and identity owner:
Canonical command comparison and conflicting-ID response:
Client wait policy and executor configuration:
Status/result lookup for the original operation:
Duplicate while running: required response / observed response:
Lost response after completion: effect count / returned original result:
Restart after effect but before result record: evidence / recovery owner:
Expired identity: admission policy / observed response:
Concurrent duplicate: admission evidence / effect count:
Physical-state evidence and freshness requirement:
Unresolved outcome: blocked dependent work / authorized recovery:
Result: NOT TESTED / accepted within stated scope / rejected
Count intended operations separately from transmission attempts, duplicate arrivals, observed effects, and unresolved outcomes. A retry that obtains a response is not automatically a successfully recovered operation if it caused duplicate work. For integration handoff, keep the agreed matrix alongside the deployment acceptance responsibilities, not only in a client retry loop.
Sources
- ROS 2 Jazzy service concepts, pinned documentation revision. RPC model, short-running scope, and action recommendation.
- Jazzy
rclpyclient, pinned implementation revision. Request sequence tracking, synchronous timeout cleanup, pending-response removal, and service readiness. Verify the installed implementation before relying on version-specific behavior. - ROS 2 Jazzy synchronous and asynchronous clients, pinned documentation revision. Python synchronous-call deadlock risks, executor progress, and asynchronous-client recommendation.
The model, retry matrix, crash-window analysis, and worksheet are Physical AI Guide’s synthesis. They demonstrate a bounded software distinction, not measured robot reliability or a safety certification.
Frequently asked questions
Does a ROS 2 service timeout mean the server did not execute the request?
No. A client wait deadline does not establish whether the server received, executed, or completed the operation. Preserve an unknown outcome and reconcile before repeating side-effecting work.
Does removing a pending rclpy service request cancel the server operation?
The reviewed Jazzy method removes client-side response tracking. It does not send a server cancellation request. Do not treat it as proof that work stopped.
Do ROS 2 asynchronous service calls prevent duplicate physical effects?
No. Async calls avoid blocking the calling thread while waiting, but application retry identity, duplicate suppression, restart recovery, and physical verification need their own contract.