{"record":{"id":"0a2a26ffe0f9da72","repo":"jumpserver/jumpserver","slug":"name-timed-out-wait-timeout-s","errorCode":null,"errorMessage":"{name} timed out, wait {timeout}s","messagePattern":"(.+?) timed out, wait (.+?)s","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"apps/libs/ansible/modules_utils/remote_client.py","lineNumber":103,"sourceCode":"        become_method=dict(type='str', required=False),\n        become_user=dict(type='str', required=False),\n        become_password=dict(type='str', required=False, no_log=True),\n        become_private_key_path=dict(type='str', required=False, no_log=True),\n\n        old_ssh_version=dict(type='bool', default=False, required=False),\n        auth_only=dict(type='bool', default=False, required=False),\n        fail_on_unknown=dict(type='bool', default=True, required=False),\n        change_succeeded=dict(type='bool', default=True, required=False),\n    )\n    return options\n\n\ndef raise_timeout(name=''):\n    def decorate(func):\n        @wraps(func)\n        def wrapper(self, *args, **kwargs):\n            def handler(signum, frame):\n                raise TimeoutError(f'{name} timed out, wait {timeout}s')\n\n            timeout = float(getattr(self, 'timeout', 0) or 0)\n            can_use_alarm = (\n                timeout > 0\n                and hasattr(signal, 'SIGALRM')\n                and hasattr(signal, 'ITIMER_REAL')\n                and threading.current_thread() is threading.main_thread()\n            )\n            if not can_use_alarm:\n                return func(self, *args, **kwargs)\n\n            previous_handler = signal.getsignal(signal.SIGALRM)\n            previous_delay, previous_interval = signal.getitimer(\n                signal.ITIMER_REAL\n            )\n            effective_timeout = timeout\n            if previous_delay > 0:\n                effective_timeout = min(effective_timeout, previous_delay)","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/jumpserver/jumpserver/blob/6ec464fabd61b95912d539455a3a5f15f5c59fe0/apps/libs/ansible/modules_utils/remote_client.py#L85-L121","documentation":"Raised by the raise_timeout decorator's signal handler in remote_client.py: each wrapped method arms a SIGALRM timer of self.timeout seconds, and when the ITIMER_REAL deadline expires the handler raises TimeoutError('{name} timed out, wait {timeout}s'). It bounds individual SSH remote operations so they cannot hang forever.","triggerScenarios":"A decorated remote-client method (connect, exec, send/recv, etc.) exceeding self.timeout seconds; a hung SSH TCP connect, a command that blocks forever, or a prompt regex that never matches the device output so recv loops until the alarm fires.","commonSituations":"Device/gateway unreachable or slow (firewall drop causing long SYN retries); recv_timeout set too low for slow network gear; a shell command waiting for stdin on a managed asset; network packet loss during large output transfer.","solutions":["Increase the timeout/recv_timeout value for the asset or task","Verify network reachability of the target (ping/telnet to port 22, check gateway chains)","Fix the command being executed so it cannot block (add timeouts, redirect stdin, run non-interactively)","Tune the prompt regex so device output is matched promptly and recv doesn't spin"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"timeout = int(params.get('recv_timeout') or 0)\nif timeout <= 0 or timeout < expected_command_duration:\n    params['recv_timeout'] = max(60, expected_command_duration * 2)","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        return client.run_command(cmd)\n    except TimeoutError as e:\n        if attempt == 2:\n            module.fail_json(msg=f'Remote op failed after retries: {e}')\n        time.sleep(2 ** attempt)","preventionTips":["Set recv_timeout proportional to the slowest expected command","Verify reachability (tcp/22 through the gateway chain) before launching tasks","Fix blocking commands: </dev/null, non-interactive flags, proper prompt regex"],"tags":["ssh","timeout","ansible","signal","remote-execution"],"backgroundTag":"operation-timed-out","analyzedSha":"6ec464fabd61b95912d539455a3a5f15f5c59fe0","analyzedAt":"2026-08-28T11:33:00.925Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}