GRPC_UNSUPPORTED_COMPRESSION grpc encoding_error ai_generated true

UNIMPLEMENTED: gRPC: 未安装 grpc-encoding: snappy 的解压缩器

UNIMPLEMENTED: grpc: Decompressor is not installed for grpc-encoding: snappy

ID: grpc/compression-algorithm-not-supported

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

版本兼容性

版本状态引入弃用备注
gRPC-go v1.65.0 active
gRPC-java v1.64.0 active
C-core v1.65.0 active

根因分析

客户端使用 'snappy' 算法压缩了消息,但服务器未注册该编码的解压缩器,因此无法解码消息。

English

The client sent a message compressed with 'snappy' algorithm, but the server does not have a decompressor registered for that encoding, so it cannot decode the message.

generic

官方文档

https://grpc.io/docs/languages/go/compression/

解决方案

  1. On the server, import the snappy package explicitly. In Go: import _ "google.golang.org/grpc/encoding/snappy". Then rebuild the server binary.
  2. On the client, change the compression algorithm to a supported one like gzip or identity: in Go dial option: grpc.WithDefaultCallOptions(grpc.UseCompressor("gzip")).
  3. For Java servers, add the dependency: <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-snappy</artifactId> <version>1.64.0</version> </dependency> and it auto-registers.

无效尝试

常见但无效的做法:

  1. 95% 失败

    Setting environment variable GRPC_GO_COMPRESSION=snappy on the server without importing the snappy package does not register the decompressor; the package must be imported explicitly.

  2. 70% 失败

    Disabling compression entirely on the client (grpc.default_compression_algorithm=identity) may break other clients that rely on compression for performance.