-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
ERROR: Failed to extract ServerMetadata from context #4605
Comments
This error message usually appears when a wrapped |
I took a look at the link you provided, but I don't think we have changed anything around that. In fact or gateway setup has been pretty consistent for over a year now, we always follow the same pattern when exposing new microservices which pretty much is: import "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
func main() {
grpcPort := config.Get("GRPC_PORT")
httpPort := config.Get("HTTP_PORT")
grpcServerEndpoint := fmt.Sprintf("%s:%s", "", grpcPort)
httpServerEndpoint := fmt.Sprintf("%s:%s", "", httpPort)
lis, err := net.Listen("tcp", grpcServerEndpoint)
if err != nil {
logger.Fatal("failed to listen", "error", err)
}
mux := runtime.NewServeMux()
httpProxyOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
authServer := auth.NewServer()
authpb.RegisterAuthenticationServiceServer(grpcServer, authServer)
authpb.RegisterAuthenticationServiceHandlerFromEndpoint(ctx, mux, grpcServerEndpoint, httpProxyOpts)
http.HandleFunc("/health", func(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, "ok") })
http.ListenAndServe(httpServerEndpoint, mux)
} Surprisingly, it started throwing that error after upgrading. One important thing to notice is that it is not breaking anything, but it is annoying and makes logs hard to read. |
Ah I think I see what's happening. In 2.21 we changed some INFO logs to ERROR level logs: #4327. You can remove these logs by overwriting the output of the grpc logger:
The error was probably always happening, but you're only noticing because we changed the log level. As to why it's happening, do you update your generator at the same time as you update the runtime library? |
Thanks! I'll give that a try.
? |
Specifically, |
Okay yeah looks like we updated the generator pretty recently, we are currently using v1.5.1 would that be an issue? |
v1.5.1 of which generator? Probably not |
Yeah sorry my bad, we actually moved to Buf Remote Plugins and updated the versions off all the generators, this is or
I can confirm that the generator version v2.21.0 matches the runtime version and we are still seeing:
|
OK great, so as I said you can turn off the grpclogger if you want, but if you want to get to the bottom of why this is happening, do you think you could provide a minimal reproducible example? This isn't expected in the general use of the gateway. |
Just noticed this error message popping up only when I send an HTTP request to an endpoint that is not found. For example, my server is serving the endpoint I'm a bit unsure why this is logged as an error at all - it seems like it is checked and logged but then everything carries on as if nothing happened (see https://github.com/grpc-ecosystem/grpc-gateway/blob/main/runtime/errors.go#L135-L138). Doesn't really seem like an error to me. In any case, standby for an example. |
@johanbrandhorst here's an example project which produces this log message when you make API calls to endpoints that aren't handled by the gateway - https://github.com/ccampo133/lambda-grpc-gateway/tree/grpc_gateway_issue_4605 (note the branch You can run the service locally and make calls to it and you'll see the message logged. For example, in some terminal, run:
Then in some other terminal:
And back in first terminal you'll see the log message:
My guess is that @andreslunchbox is seeing these logs on his AWS deployment due to miscellaneous web traffic (scrapers, etc.). |
Maybe this should just get the same treatment as #4594 and we just return the error instead of logging it? |
I think that's probably a fine approach after looking at the code a bit closer. I will probably take a stab at submitting a PR if I stumble upon some free time soon, but please don't wait for me. I appreciate the responses! |
we stumbled upon the same problem. Can confirm that this log message only appears for requests which can't be handled (e.g. for the favicon when testing in a browser). Using the workaround atm |
After upgrading from:
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1
To:
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0
I am encountering the following error multiple times even when I'm not making API calls to the gateway:
gRPC-Gateway version: v2.21.0
Environment: Amazon Elastic Kubernetes Service (EKS) + AWS ALB Ingress Controller
Additional Context
I've observed this error consistently after upgrading the gateway version. It appears when the gateway is behind an AWS ALB Ingress Controller as it does not show up in local development when using an NGINX ingress.
The text was updated successfully, but these errors were encountered: