Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflection Header grpc-reflection-js #2105

Open
mbazos opened this issue May 7, 2021 · 3 comments
Open

Reflection Header grpc-reflection-js #2105

mbazos opened this issue May 7, 2021 · 3 comments
Labels

Comments

@mbazos
Copy link

mbazos commented May 7, 2021

I am working with the graphql-mesh gRPC input handler and specifically with the gRPC reflection API as to get the protos dynamically from the gRPC service. My question is that we have several gRPC services and the reflection API requires to listen on the root path.

We use tools like grpcurl which have an option for a -reflect-header and then our infrastructure knows when it sees that header to route that request to a specific gRPC service. Here is an example of grpcurl using the -reflect-header:

grpcurl -reflect-header grpc-service:proto.MyGrpcService -d '{"name":  "mike"}' localhost:9090 proto.MyGrpcService/hello

My question is:

I am not sure if to accomplish this the underlying library grpc-reflection-js needs to support this first

@ardatan
Copy link
Owner

ardatan commented May 11, 2021

Opened an issue on grpc-reflection-js
redhoyasa/grpc-reflection-js#8

@redhoyasa
Copy link

Hi, I'd like to know more about the reflect-header. From my understanding,reflect-header will be added to gRPC metadata but used only on reflection request. Is that correct?

@mbazos
Copy link
Author

mbazos commented Jun 17, 2021

@redhoyasa Yes this would only be for the reflection request. If you can please take a look at this utility https://github.com/fullstorydev/grpcurl

From the help:

  -reflect-header value
    	Additional reflection headers in 'name: value' format. May specify more
    	than one via multiple flags. These headers will *only* be used during
    	reflection requests and will be excluded when invoking the requested RPC
    	method.

The main reason for this is depending on your infrastructure/routing the reflection API needs to be on the root of the service and if you have more than one gRPC service routed through the same gateway the reflection request wouldn't know the right underlying service to hit.

For example given the two grpc services:
https://sample-gateway/grpc-service-one
https://sample-gateway/grpc-service-two

imagine sample-gateway could be ngnix or istio proxy. If you make a grpc call to https://sample-gateway/grpc-service-one it works fine, but if you do the reflection request it expects the call to be made on https://sample-gateway/ which then ngix/istio or some other proxy would need to identify the reflection request and route it to the proper underlying grpc service.

Reading the gRPC reflection spec, the reflection API should always be served on the root so this isn't something that's configurable or should be modified. I believe this is the reason grpcurl added reflect-header to specifically satisfy this requirement.

@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants