curl算子_grpcurl使用

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

问题解决

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值