首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >grpcurl使用

grpcurl使用

作者头像
golangLeetcode
发布2022-08-02 19:04:17
发布2022-08-02 19:04:17
8530
举报

1,grpcurl 127.0.0.1:57904 list

Failed to dial target host "127.0.0.1:57904": tls: first record does not look like a TLS handshake

原因grpc默认是https

2,grpcurl -plaintext 127.0.0.1:57904 list

grpc.health.v1.Health

grpc.reflection.v1alpha.ServerReflection

xxx.svc.xx.XXService

加-plaintext 走http 解决

3,grpcurl -plaintext 127.0.0.1:57904 list xxx.svc.xx.XXService

xxx.svc.xx.XXService.xxMethod

xxx.svc.xx.XXService.yyMethod

前提是服务端起了reflection

4,grpcurl -plaintext 127.0.0.1:57904 xxx.svc.xx.XXService/yyMethod

ERROR:

Code: InvalidArgument

Message: xxx

缺少参数

5,grpcurl -plaintext 127.0.0.1:57904 describe xxx.svc.xx.XXService

e xxx.svc.xx.XXService is a service:

service XXService {

rpc yyMethod ( .google.protobuf.Empty ) returns ( .google.protobuf.Empty );

6.grpcurl -plaintext 127.0.0.1:57904 describe xxx.svc.xx.XXService.yyMethod

xxx.svc.xx.XXService.yyMethod is a method:

rpc yyMethod ( .xxx.svc.xx.XXService.yyMethodRequest ) returns ( .xxx.svc.xx.XXService.yyMethodResponse );

7.grpcurl -plaintext 127.0.0.1:57904 describe .xxx.svc.xx.yyMethodRequest

.xxx.svc.xx.yyMethodRequest is a message:

message yyMethodRequest {

string xxx = 1;

int64 yyy = 2;

}

8.grpcurl -plaintext 127.0.0.1:57904 -d '{"xxx":"12133","yyy":0}' xxx.svc.xx.XXService/yyMethod

Too many arguments.

原因:请求参数位置不对

9.grpcurl -plaintext -d '{"xxx":"12133","yyy":0}' 127.0.0.1:57904 xxx.svc.xx.XXService/yyMethod

ERROR:

Code: PermissionDenied

原因 缺少meta参数(header)

10.grpcurl -plaintext -d '{"xxx":"12133","yyy":0}' -H '"Xx":1234' 127.0.0.1:57904 xxx.svc.xx.XXService/yyMethod

Error invoking method "xxx.svc.xx.XXService/yyMethod": rpc error: code = Internal desc = failed to query for service descriptor "xxx.svc.xx.XXService/yyMethod": stream terminated by RST_STREAM with error code: PROTOCOL_ERROR

原因:没有指定proto 文件

11.grpcurl -plaintext -d '{"xxx":"12133","yyy":0}' -H '"Xx":1234' -proto "~/go/protos/xxx.proto" 127.0.0.1:57904 xxx.svc.xx.XXService/yyMethod

Failed to process proto source files.: could not parse given files: %!v(PANIC=Error method: runtime error: invalid memory address or nil pointer dereference)

原因:没有指定依赖文件的目录

12. grpcurl -plaintext -d '{"xxx":"12133","yyy":0}' -H '"Xx":1234' -import-path "/go/protos/" -proto "/go/protos/xxx.proto" 127.0.0.1:57904 xxx.svc.xx.XXService/yyMethod

ERROR:

Code: Internal

Message: stream terminated by RST_STREAM with error code: PROTOCOL_ERROR

原因:header 错误,原因header 里多了“

13.grpcurl -plaintext -emit-defaults 127.0.0.1:57904 xxx.svc.xx.XXService/yyMethod

ERROR:

Code: InvalidArgument

Message: xxx or yyy is required

14.grpcurl -plaintext -d '{"xxx":"12133","yyy":0}' -H 'Xx:1234' -import-path "/go/protos/" -proto "/go/protos/xxx.proto" 127.0.0.1:57904 xxx.svc.xx.XXService/yyMethod

问题解决

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-02-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 golang算法架构leetcode技术php 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档