{"record":{"id":"19bb4b1e3173ad6c","repo":"NationalSecurityAgency/ghidra","slug":"not-connected-19bb4b","errorCode":null,"errorMessage":"Not connected","messagePattern":"Not connected","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py","lineNumber":118,"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":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py#L100-L136","documentation":"Raised by State.require_client when STATE.client is None. The client is the socket connection to Ghidra's trace-rpc service, established by ghidra_trace_connect or ghidra_trace_listen. Any command that needs the trace-rpc connection will hit this guard if connect has not been called or was reset.","triggerScenarios":"A command calls STATE.require_client() before ghidra_trace_connect or ghidra_trace_listen has established the connection. This also fires after ghidra_trace_disconnect resets the client.","commonSituations":"User issued trace commands before connecting to Ghidra. The connection was dropped or disconnected and not re-established. ghidra_trace_disconnect was called and then commands were issued without re-connecting.","solutions":["Run 'ghidra_trace_connect <host:port>' or 'ghidra_trace_listen' before issuing trace commands.","After a disconnect, re-connect before the next operation.","Check STATE.client is not None before calling require_client-dependent commands."],"exampleFix":"# before: commands without connect\nSTATE.require_client()  # client is None -> RuntimeError\n\n# after: connect first\nghidra_trace_connect('127.0.0.1:12345')\nclient = STATE.require_client()","handlingStrategy":"validation","validationCode":"if STATE.client is None:\n    raise RuntimeError(\"Not connected; run 'ghidra trace connect <host:port>' first\")","typeGuard":"def is_connected() -> bool:\n    return STATE.client is not None","tryCatchPattern":"try:\n    client = STATE.require_client()\nexcept RuntimeError:\n    ghidra_trace_connect('127.0.0.1:12345')\n    client = STATE.require_client()","preventionTips":["Always connect via 'ghidra trace connect' or 'ghidra trace listen' before trace commands.","Re-connect after a disconnect before issuing further commands.","Check STATE.client is not None before calling require_client-dependent operations."],"tags":["x64dbg","debugger-agent","state-machine","runtimeerror","connection","initialization"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}