{"record":{"id":"c103dd5cfcd00b3f","repo":"NationalSecurityAgency/ghidra","slug":"not-connected-c103dd","errorCode":null,"errorMessage":"Not connected","messagePattern":"Not connected","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py","lineNumber":105,"sourceCode":"    def require_mm(self) -> arch.DefaultMemoryMapper:\n        if self.memory_mapper is None:\n            raise RuntimeError(\"No memory mapper\")\n        return self.memory_mapper\n\n    def require_rm(self) -> arch.DefaultRegisterMapper:\n        if self.register_mapper is None:\n            raise RuntimeError(\"No register mapper\")\n        return self.register_mapper\n\n\nclass State(object):\n\n    def __init__(self) -> None:\n        self.reset_client()\n\n    def require_client(self) -> Client:\n        if self.client is None:\n            raise RuntimeError(\"Not connected\")\n        return self.client\n\n    def require_no_client(self) -> None:\n        if self.client != None:\n            raise RuntimeError(\"Already connected\")\n\n    def reset_client(self) -> None:\n        self.client: Optional[Client] = None\n        self.reset_trace()\n\n    def require_trace(self) -> Trace[Extra]:\n        if self.trace is None:\n            raise RuntimeError(\"No trace active\")\n        return self.trace\n\n    def require_no_trace(self) -> None:\n        if self.trace != None:\n            raise RuntimeError(\"Trace already started\")","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py#L87-L123","documentation":"Raised as RuntimeError by State.require_client() when STATE.client is None — i.e. no connection to Ghidra's trace RMI bridge exists yet. Any trace command that needs the socket must connect first via ghidra_trace_connect()/ghidra_trace_listen().","triggerScenarios":"Calling ghidra_trace_start(), start_trace(), or any client-dependent command before ghidra_trace_connect()/ghidra_trace_listen() succeeded; after ghidra_trace_disconnect() reset the client.","commonSituations":"Running trace commands in the wrong order; connect() failed silently (port closed) leaving client None; reconnecting after a disconnect without a fresh connect.","solutions":["Call ghidra_trace_connect('host:port') (or ghidra_trace_listen) and confirm the 'Connected ...' message before trace commands.","Guard: if STATE.client is None: report 'connect first'.","If a prior connect raised, inspect the port/host and retry connect before continuing."],"exampleFix":"// before\nSTATE.require_client().create_trace(...)  # RuntimeError: Not connected\n// after\nif STATE.client is None:\n    ghidra_trace_connect(address)\nSTATE.require_client().create_trace(...)","handlingStrategy":"validation","validationCode":"if STATE.client is None:\n    raise RuntimeError('call ghidra_trace_connect/listen first')\nclient = STATE.require_client()","typeGuard":"def is_connected() -> bool:\n    return getattr(STATE, 'client', None) is not None","tryCatchPattern":"try:\n    client = STATE.require_client()\nexcept RuntimeError as e:\n    if 'Not connected' in str(e):\n        ghidra_trace_connect(address); client = STATE.require_client()\n    else:\n        raise","preventionTips":["Call ghidra_trace_connect('host:port') before any client-dependent command.","Confirm the 'Connected ...' message before proceeding.","Re-connect after ghidra_trace_disconnect() rather than reusing a reset client."],"tags":["drgn","connection","state-machine","precondition"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}