1 回答

TA贡献1795条经验 获得超7个赞
您分享的错误表明您的服务器不支持 gzip 压缩。
最快的解决方法是在客户端的调用选项中不使用 gzip 压缩,方法是删除以下行:
options: CallOptions(compression: const GzipCodec()),
从你的飞镖代码。
go-grpc 库在packagegithub.com/grpc/grpc-go/encoding/gzip中实现了 gzip 压缩编码,但它是实验性的,因此在生产中使用它可能不明智;或者至少你应该密切注意它:
// Package gzip implements and registers the gzip compressor
// during the initialization.
//
// Experimental
//
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
// later release.
如果你想在你的服务器中使用它,你只需要导入包;包中没有面向用户的代码:
import (
_ "github.com/grpc/grpc-go/encoding/gzip"
)
关于 grpc-go 压缩的文档提到了上面的这个包作为你如何实现这样一个压缩器的例子。
因此,您可能还想将代码复制到更稳定的位置并自行负责维护它,直到有稳定的受支持版本为止。
- 1 回答
- 0 关注
- 157 浏览
添加回答
举报