curl算子_grpcurl使用

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

大家好,我是讯享网,很高兴认识大家。

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

问题解决

小讯
上一篇 2025-04-09 18:01
下一篇 2025-02-09 14:17

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/40264.html