亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何解決“沒有為 grpc-encoding 安裝解壓器”的問題?

如何解決“沒有為 grpc-encoding 安裝解壓器”的問題?

Go
慕虎7371278 2023-02-28 20:30:06
當我從 Dart 調用 gRPC Golang 服務器時出現此錯誤:捕獲錯誤:gRPC 錯誤(代碼:12,代碼名稱:UNIMPLEMENTED,消息:grpc:未為 grpc 編碼“gzip”安裝解壓縮器,詳細信息:[],rawResponse:null,預告片:{})我已閱讀https://github.com/bradleyjkemp/grpc-tools/issues/19,它似乎不適用于我的問題。服務器在 Gcloud Ubuntu 上運行 1.19.2。Dart 在 Mac Monterey 上運行 2.18.2我有一個調用 Go 服務器的 Dart 客戶端。兩者似乎都使用 GZIP 進行壓縮。飛鏢原型syntax = "proto3";option java_multiple_files = true;option java_package = "io.grpc.examples.helloworld";option java_outer_classname = "HelloWorldProto";option objc_class_prefix = "HLW";package helloworld;// The greeting service definition.service Greeter {  // Sends a greeting  rpc SayHello (HelloRequest) returns (HelloReply) {}}// The request message containing the user's name.message HelloRequest {  string name = 1;}// The response message containing the greetingsmessage HelloReply {  string message = 1;}去原型:syntax = "proto3";option go_package = "google.golang.org/grpc/examples/helloworld/helloworld";option java_multiple_files = true;option java_package = "io.grpc.examples.helloworld";option java_outer_classname = "HelloWorldProto";package helloworld;// The greeting service definition.service Greeter {  // Sends a greeting  rpc SayHello (HelloRequest) returns (HelloReply) {}}// The request message containing the user's name.message HelloRequest {  string name = 1;}// The response message containing the greetingsmessage HelloReply {  string message = 1;}飛鏢客戶端代碼:import 'package:grpc/grpc.dart';import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';Future<void> main(List<String> args) async {  final channel = ClientChannel(    'ps-dev1.savup.com',    port: 54320,    options: ChannelOptions(      credentials: ChannelCredentials.insecure(),      codecRegistry:          CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),    ),  );Go gRPC 服務器與 Go gRPC 客戶端和 BloomRPC 配合良好??偟膩碚f,我是 gRPC 的新手,也是 Dart 的新手。在此先感謝您為解決此問題提供的任何幫助。
查看完整描述

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 壓縮的文檔提到了上面的這個包作為你如何實現這樣一個壓縮器的例子。


因此,您可能還想將代碼復制到更穩定的位置并自行負責維護它,直到有穩定的受支持版本為止。


查看完整回答
反對 回復 2023-02-28
  • 1 回答
  • 0 關注
  • 146 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號