{
  "id": "ros2/ros2-service-client-wait-timeout",
  "signature": "rclpy.service.ServiceException: Service '/my_service' is not available after waiting 10.0 seconds",
  "signature_zh": "rclpy.service.ServiceException：等待 10.0 秒后服务 '/my_service' 仍不可用",
  "regex": "Service '/[^']+' is not available after waiting [0-9.]+ seconds",
  "domain": "ros2",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The service client timed out waiting for the service to become available, typically because the service server is not running, not started, or the network/domain ID prevents discovery.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务客户端等待服务变为可用时超时，通常因为服务服务器未运行、未启动或网络/域 ID 阻止了发现。",
  "versions": [
    {
      "version": "ros2:humble",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ros2:iron",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rclpy:4.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "rclcpp:18.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing the timeout value to 30 or 60 seconds",
      "why_fails": "The service server is not running at all; a longer timeout just delays the failure.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Restarting the client node without checking the service server status",
      "why_fails": "Restarting the client does not start the service server; the root cause is the missing server.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Verify the service server is running and accessible. Use: ros2 service list | grep /my_service\n\nIf not listed, start the server node: ros2 run my_package my_service_server_node\n\nThen retry the client.",
      "success_rate": 0.95,
      "how": "Verify the service server is running and accessible. Use: ros2 service list | grep /my_service\n\nIf not listed, start the server node: ros2 run my_package my_service_server_node\n\nThen retry the client.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a retry loop with exponential backoff in the client code instead of a single wait. Example in Python:\nimport rclpy\nfrom rclpy.node import Node\nfrom std_srvs.srv import Empty\n\nclass MyClient(Node):\n    def __init__(self):\n        super().__init__('my_client')\n        self.cli = self.create_client(Empty, '/my_service')\n        while not self.cli.wait_for_service(timeout_sec=1.0):\n            self.get_logger().info('Service not available, retrying...')\n        # Proceed with service call",
      "success_rate": 0.9,
      "how": "Add a retry loop with exponential backoff in the client code instead of a single wait. Example in Python:\nimport rclpy\nfrom rclpy.node import Node\nfrom std_srvs.srv import Empty\n\nclass MyClient(Node):\n    def __init__(self):\n        super().__init__('my_client')\n        self.cli = self.create_client(Empty, '/my_service')\n        while not self.cli.wait_for_service(timeout_sec=1.0):\n            self.get_logger().info('Service not available, retrying...')\n        # Proceed with service call",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "验证服务服务器是否运行并可访问。使用：ros2 service list | grep /my_service\n\n如果未列出，启动服务器节点：ros2 run my_package my_service_server_node\n\n然后重试客户端。",
    "在客户端代码中添加带指数退避的重试循环，而非单一等待。Python 示例：\nimport rclpy\nfrom rclpy.node import Node\nfrom std_srvs.srv import Empty\n\nclass MyClient(Node):\n    def __init__(self):\n        super().__init__('my_client')\n        self.cli = self.create_client(Empty, '/my_service')\n        while not self.cli.wait_for_service(timeout_sec=1.0):\n            self.get_logger().info('服务不可用，正在重试...')\n        # 继续服务调用"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros2.org/latest/api/rclpy/api/services.html",
  "official_doc_section": null,
  "error_code": "ROS2-3002",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-09-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}