“Could not load server reflection. Details: unknown error” 当使用 GRPC 服务器反射时。

huangapple go评论76阅读模式
英文:

Postman - "Could not load server reflection. Details: unknown error" when using GRPC server reflection

问题

I am trying to use Postman on my GRPC service as described here: https://learn.microsoft.com/en-us/aspnet/core/grpc/test-tools?view=aspnetcore-6.0

Unfortunately, I am getting the error below:
> Could not load server reflection.
Details: unknown error

“Could not load server reflection. Details: unknown error” 当使用 GRPC 服务器反射时。

In Console I can see a bunch of info messages, no errors:

> info: Microsoft.AspNetCore.Hosting.Diagnostics2
> Request finished HTTP/2 POST http://localhost:5001/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo
> application/grpc - - 200 - application/grpc 57.0449ms
info: Microsoft.AspNetCore.Hosting.Diagnostics2
> Request finished HTTP/2 POST http://localhost:5001/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo
> application/grpc - - 200 - application/grpc 158.2632ms
> info:
> Microsoft.AspNetCore.Routing.EndpointMiddleware1
> Executed endpoint 'gRPC - /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'

Not sure what can be done to investigate and fix.
If I import the proto files to Postman, I can execute an endpoint and it works OK.

Some details:

  • I am using http/2 over HTTP.
  • Postman Version 10.14.5
  • All grpc packages are version 2.50.0
  • I am tried a few ways of enabling http/2 as in this answer

Any help appreciated!

英文:

I am trying to use Postman on my GRPC service as described here: https://learn.microsoft.com/en-us/aspnet/core/grpc/test-tools?view=aspnetcore-6.0

Unfortunately, I am getting the error below:
> Could not load server reflection.
Details: unknown error

“Could not load server reflection. Details: unknown error” 当使用 GRPC 服务器反射时。

In Console I can see a bunch of info messages, no errors:

> info: Microsoft.AspNetCore.Hosting.Diagnostics2
> Request finished HTTP/2 POST http://localhost:5001/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo
> application/grpc - - 200 - application/grpc 57.0449ms
info: Microsoft.AspNetCore.Hosting.Diagnostics2
> Request finished HTTP/2 POST http://localhost:5001/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo
> application/grpc - - 200 - application/grpc 158.2632ms
> info:
> Microsoft.AspNetCore.Routing.EndpointMiddleware1
> Executed endpoint 'gRPC - /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo'

Not sure what can be done to investigate and fix.
If I import the proto files to Postman, I can execute an endpoint and it works OK.

Some details:

  • I am using http/2 over HTTP.
  • Postman Version 10.14.5
  • All grpc packages are version 2.50.0
  • I am tried a few ways of enabling http/2 as in this answer

Any help appreciated!

答案1

得分: 1

我已经使用 https://github.com/fullstorydev/grpcurl 代替 Postman 连接到服务。它立即给我一个有意义的错误:

未能解析符号 "My.Service":
未找到符号:My.Service
造成原因:找不到文件:google/protobuf/Empty.proto

这有点令人困惑,尤其是服务正常运行。但事实证明,我的导入定义大小写不正确(请参见 https://github.com/fullstorydev/grpcurl/issues/203)。

我有 import "google/protobuf/Empty.proto"; 而不是 import "google/protobuf/empty.proto";

纠正后,无论是在 Postman 还是 Grpcurl 中,它都可以正常工作。

值得一提的是 - Grpcurl 并不一定比 Postman 具有更好的错误处理能力。
这取决于情况 - 例如,当使用不正确的协议(HTTP 1 而不是 HTTP 2)时,Grpcurl 只会显示 Failed to dial target host "localhost:5001": context deadline exceeded,而 Postman 的错误更有意义:INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error

英文:

I have used https://github.com/fullstorydev/grpcurl instead of Postman to connect to the service. It immediately gave me meaningful error:

> Failed to resolve symbol "My.Service":
Symbol not found: My.Service
caused by: File not found: google/protobuf/Empty.proto

It was a bit puzzling, especially that the service works OK.
However, it turns out that my import definitions had an incorrect casing (see https://github.com/fullstorydev/grpcurl/issues/203).

I had "google/protobuf/Empty.proto"; instead of import "google/protobuf/empty.proto";.

After correcting it works fine both in Postman and Grpcurl.

For the record - it's not that Grpcurl has better error handling than Postman.
It depends - for example, when an incorrect protocol is used (HTTP 1 instead of HTTP 2), Grpcurl just says Failed to dial target host "localhost:5001": context deadline exceeded whereas Postman's error is more meaningful: INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error

huangapple
  • 本文由 发表于 2023年5月25日 21:10:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76332660.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定