t8y2/dbx · error
invalid RocketMQ frame length: %d
Error message
invalid RocketMQ frame length: %d
What it means
readRemotingFrame reads the 4-byte big-endian length prefix of a RocketMQ remoting frame and rejects any length that is non-positive or exceeds the 64MiB safety cap. This guard prevents allocating huge buffers from corrupt, truncated, or non-RocketMQ streams. It indicates the connection is not delivering a valid RocketMQ remoting protocol stream.
Source
Thrown at agents/drivers/rocketmq/routing.go:249
}
encoded, err := command.Encode()
if err != nil {
return err
}
if _, err := destination.Write(encoded); err != nil {
return err
}
}
}
func readRemotingFrame(reader io.Reader) ([]byte, error) {
header := make([]byte, 4)
if _, err := io.ReadFull(reader, header); err != nil {
return nil, err
}
length := int(binary.BigEndian.Uint32(header))
if length <= 0 || length > 64*1024*1024 {
return nil, fmt.Errorf("invalid RocketMQ frame length: %d", length)
}
frame := make([]byte, 4+length)
copy(frame, header)
if _, err := io.ReadFull(reader, frame[4:]); err != nil {
return nil, err
}
return frame, nil
}
func signCommand(command *remoting.RemotingCommand, accessKey, secretKey string) {
if accessKey == "" && secretKey == "" {
return
}
if command.ExtFields == nil {
command.ExtFields = map[string]string{}
}
delete(command.ExtFields, "Signature")
command.ExtFields["AccessKey"] = accessKeyView on GitHub (pinned to c0390bff16)
Solutions
- Verify the configured broker address and port actually serve the RocketMQ remoting protocol (default 9876/10911), not an HTTP or console endpoint
- Check for TLS/proxy interference: connect directly to the broker to see if the error disappears
- Capture the first bytes of the stream (tcpdump/wireshark) to confirm a plausible length prefix
- Upgrade/align driver and broker versions to ensure remoting protocol compatibility
Example fix
// before addr := "localhost:8080" // console/HTTP port client := admin.New(addr) // after addr := "localhost:9876" // broker remoting port client := admin.New(addr)
Defensive patterns
Strategy: validation
Validate before calling
// ensure addr points at the remoting port before connecting
u, err := net.ResolveTCPAddr("tcp", brokerAddr)
if err != nil || u.Port == 80 || u.Port == 8080 {
return fmt.Errorf("brokerAddr %q does not look like a remoting endpoint", brokerAddr)
} Try / catch
frame, err := readRemotingFrame(conn)
if err != nil {
var protoErr *protocolError
if errors.As(err, &protoErr) && strings.Contains(protoErr.Error(), "invalid RocketMQ frame length") {
// reconnect to correct broker endpoint / reset stream
}
return err
} Prevention
- Use the broker remoting port (default 9876/10911), never console or HTTP ports
- Connect directly to brokers in dev to rule out TLS/proxy mangling
- Cap message sizes well under 64MiB so responses never approach the limit
- Pin driver and broker versions known to interoperate
When it happens
Trigger: Calling forward/readRemotingFrame against a socket whose stream is not a RocketMQ remoting response: garbage bytes, a truncated/corrupted header, an intermediate proxy speaking a different protocol, or a length field exceeding 64*1024*1024.
Common situations: Pointing the driver at the wrong port (e.g. HTTP/health endpoint instead of the remoting port 9876); a firewall or LB mangling the stream; reading from a TLS-wrapped connection without TLS setup; broker protocol/version mismatch.
Related errors
- ZooKeeper SASL response is truncated
- send ZooKeeper connect request: %w
- read ZooKeeper connect response: %w
- query consumer status for group %s on all masters: %w
- query consumer lag for group %s on all masters: %w
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/ae9d8393c4b90eed.
Report an issue: GitHub.