# 内部错误：gRPC：无效的消息编码 "custom-enc"

- **ID:** `grpc/grpc-invalid-message-encoding`
- **领域:** grpc
- **类别:** encoding_error
- **错误码:** `EENC`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

客户端或服务器发送了带有对端不支持的 Content-Encoding 或 Message-Encoding 的消息。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC v1.63.0 | active | — | — |
| gRPC v1.60.0 | active | — | — |
| gRPC v1.57.0 | active | — | — |
| Go gRPC v1.62.0 | active | — | — |

## 解决方案

1. ```
   在客户端和服务器上使用相同名称注册自定义编解码器，例如通过 `grpc.RegisterCompressor` 或 `WithDefaultCallOptions(grpc.UseCompressor('custom-enc'))`。
   ```
2. ```
   通过从客户端调用选项中移除自定义编码，回退到标准 gRPC 压缩（gzip）。
   ```

## 无效尝试

- **Adding the encoding to server's supported list without implementing the codec** — The server will accept the encoding but fail to decompress, causing DATA_LOSS. (80% 失败率)
- **Disabling all compression on the client** — The error is about unrecognized encoding, not compression being enabled. (60% 失败率)
