EENC grpc encoding_error ai_generated true

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

INTERNAL: grpc: invalid message encoding "custom-enc"

ID: grpc/grpc-invalid-message-encoding

其他格式: JSON · Markdown 中文 · English
85%修复率
87%置信度
1证据数
2024-09-05首次发现

版本兼容性

版本状态引入弃用备注
gRPC v1.63.0 active
gRPC v1.60.0 active
gRPC v1.57.0 active
Go gRPC v1.62.0 active

根因分析

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

English

Client or server sends a message with a custom Content-Encoding or Message-Encoding that the peer does not support.

generic

官方文档

https://grpc.io/docs/guides/compression/#custom-compression

解决方案

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

无效尝试

常见但无效的做法:

  1. Adding the encoding to server's supported list without implementing the codec 80% 失败

    The server will accept the encoding but fail to decompress, causing DATA_LOSS.

  2. Disabling all compression on the client 60% 失败

    The error is about unrecognized encoding, not compression being enabled.