t8y2/dbx · error

RocketMQ agent is not connected

Error message

RocketMQ agent is not connected

What it means

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.

Source

Thrown at agents/drivers/rocketmq/server.go:123

		return a.sendMessage(params)
	case "mq_list_acls":
		return a.listACLs(params)
	case "mq_create_acls":
		return a.createACLs(params)
	case "mq_delete_acls":
		return a.deleteACLs(params)
	case "mq_describe_cluster":
		return a.describeCluster(params)
	default:
		return nil, fmt.Errorf("unknown method: %s", method)
	}
}

func (a *rocketMQAgent) requireClient() (*admin.Client, connectionConfig, error) {
	a.mu.RLock()
	defer a.mu.RUnlock()
	if a.client == nil {
		return nil, connectionConfig{}, errors.New("RocketMQ agent is not connected")
	}
	return a.client, a.connection, nil
}

func (a *rocketMQAgent) close() {
	a.mu.Lock()
	defer a.mu.Unlock()
	if a.client != nil {
		_ = a.client.Close()
	}
	if a.proxies != nil {
		a.proxies.Close()
	}
	a.client = nil
	a.proxies = nil
	a.connection = connectionConfig{}
	a.clusterName = ""
	a.brokerAddr = ""

View on GitHub (pinned to c0390bff16)

Solutions

  1. Call connect with valid connection config before any admin operation
  2. Check the connect result/error before dispatching subsequent operations
  3. Reconnect the agent if close() was called (client is not auto-restored)
  4. Serialize shutdown so no operations are dispatched after close

Example fix

// before
await agent.dispatch("describeCluster", {}); // may run before connect
// after
await agent.dispatch("connect", { nameServers: ["rmq:9876"] });
await agent.dispatch("describeCluster", {});
Defensive patterns

Strategy: try-catch

Validate before calling

const cfg = await agent.dispatch("test_connection", params); // or check internal connected flag
if (!cfg.ok) throw new Error("connect before admin operations");

Type guard

function isConnected(a) { return a != null && a.client != null; }

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/6140ef895b0d9558. Report an issue: GitHub.