{"record":{"id":"da849535b95fe5e1","repo":"NationalSecurityAgency/ghidra","slug":"not-connected","errorCode":null,"errorMessage":"Not connected","messagePattern":"Not connected","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py","lineNumber":121,"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":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py#L103-L139","documentation":"Thrown by State.require_client() when the client (connection to the Ghidra trace server) is None — no active connection exists. The dbgeng agent must connect to a Ghidra trace connector before issuing any commands that communicate with Ghidra. This RuntimeError is the guard for all commands requiring an active trace-bridge connection.","triggerScenarios":"STATE.require_client() is called by any command needing the trace connector, but STATE.client is None (from reset_client or initial state). Happens when commands like ghidra_trace_putmem, ghidra_trace_start are issued before ghidra_trace_connect has been called.","commonSituations":"The user forgot to call ghidra_trace_connect('host:port') before issuing trace commands. The connection was dropped or reset and not re-established. The script execution order doesn't connect first.","solutions":["Call ghidra_trace_connect(address) with the correct host:port before any trace commands.","Verify the Ghidra trace connector plugin is running and listening on the expected port.","Check for a dropped connection — reconnect if network issues occurred.","Ensure scripts call connect before any other trace operations."],"exampleFix":"# Before: issuing commands without connecting\n# ghidra_trace_putmem(...)\n#\n# After: connect first\n# ghidra_trace_connect('127.0.0.1:12345')\n# ghidra_trace_putmem(...)","handlingStrategy":"validation","validationCode":"# Before commands requiring a client, check connection state:\nif STATE.client is not None:\n    # proceed with command\nelse:\n    ghidra_trace_connect('127.0.0.1:12345')","typeGuard":"def is_connected(state) -> bool:\n    return state.client is not None","tryCatchPattern":"try:\n    client = STATE.require_client()\nexcept RuntimeError as e:\n    if str(e) == 'Not connected':\n        ghidra_trace_connect(address)\n        client = STATE.require_client()\n    else:\n        raise","preventionTips":["Always call ghidra_trace_connect before any trace-related commands.","Verify the Ghidra trace connector plugin is active and listening.","In scripts, connect at the start and disconnect at the end.","Handle dropped connections with reconnect logic."],"tags":["debugger-agent","connection","client","state-management","python"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}