{"record":{"id":"6140ef895b0d9558","repo":"t8y2/dbx","slug":"rocketmq-agent-is-not-connected","errorCode":null,"errorMessage":"RocketMQ agent is not connected","messagePattern":"RocketMQ agent is not connected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/server.go","lineNumber":123,"sourceCode":"\t\treturn a.sendMessage(params)\n\tcase \"mq_list_acls\":\n\t\treturn a.listACLs(params)\n\tcase \"mq_create_acls\":\n\t\treturn a.createACLs(params)\n\tcase \"mq_delete_acls\":\n\t\treturn a.deleteACLs(params)\n\tcase \"mq_describe_cluster\":\n\t\treturn a.describeCluster(params)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown method: %s\", method)\n\t}\n}\n\nfunc (a *rocketMQAgent) requireClient() (*admin.Client, connectionConfig, error) {\n\ta.mu.RLock()\n\tdefer a.mu.RUnlock()\n\tif a.client == nil {\n\t\treturn nil, connectionConfig{}, errors.New(\"RocketMQ agent is not connected\")\n\t}\n\treturn a.client, a.connection, nil\n}\n\nfunc (a *rocketMQAgent) close() {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\tif a.client != nil {\n\t\t_ = a.client.Close()\n\t}\n\tif a.proxies != nil {\n\t\ta.proxies.Close()\n\t}\n\ta.client = nil\n\ta.proxies = nil\n\ta.connection = connectionConfig{}\n\ta.clusterName = \"\"\n\ta.brokerAddr = \"\"","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/server.go#L105-L141","documentation":"rocketMQAgent.requireClient guards every admin operation (listACLs, createACLs, deleteACLs, describeCluster, listConsumerGroups, describeConsumerGroup) by checking that the admin client was established at connect time. If the agent was never connected, or close() already released the client, the operation cannot proceed and this error is returned.","triggerScenarios":"Dispatching any RocketMQ admin operation before calling connect; dispatching after close/shutdown; connect failed earlier but the error was ignored and operations were attempted anyway.","commonSituations":"Process restart with stale in-memory state; a connection teardown raced with an in-flight request; missing/invalid connection config so connect silently failed; calling the agent from another component unaware it was closed.","solutions":["Call connect with valid connection config before any admin operation","Check the connect result/error before dispatching subsequent operations","Reconnect the agent if close() was called (client is not auto-restored)","Serialize shutdown so no operations are dispatched after close"],"exampleFix":"// before\nawait agent.dispatch(\"describeCluster\", {}); // may run before connect\n// after\nawait agent.dispatch(\"connect\", { nameServers: [\"rmq:9876\"] });\nawait agent.dispatch(\"describeCluster\", {});","handlingStrategy":"try-catch","validationCode":"const cfg = await agent.dispatch(\"test_connection\", params); // or check internal connected flag\nif (!cfg.ok) throw new Error(\"connect before admin operations\");","typeGuard":"function isConnected(a) { return a != null && a.client != null; }","tryCatchPattern":"try { await agent.dispatch(\"describeCluster\", {}); } catch (e) { if (/not connected/.test(e.message)) { await agent.dispatch(\"connect\", config); await agent.dispatch(\"describeCluster\", {}); } else throw e; }","preventionTips":["Always connect first and check the result","Treat close() as terminal; recreate the agent to reconnect","Sequence shutdown so no ops run after close","Wrap operation dispatch with an auto-reconnect helper"],"tags":["rocketmq","not-connected","lifecycle"],"backgroundTag":"not-connected","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}