3
votes

In one of my services that happens to be my loadbalancer, I am getting the following error when calling the server method in one of my deployed services:

rpc error: code = Unimplemented desc = unknown service fooService.FooService

I have a few other services set up with gRPC and they work fine. It just seems to be this one and I am wondering if that is because it is the loadbalancer?

func GetResult(w http.ResponseWriter, r *http.Request) {

    conn, errOne := grpc.Dial("redis-gateway:10006", grpc.WithInsecure())       
    defer conn.Close()

    rClient := rs.NewRedisGatewayClient(conn)
    result , errTwo := rClient.GetData(context.Background(), &rs.KeyRequest{Key: "trump", Value: "trumpVal"}, grpc.WithInsecure())

    fmt.Fprintf(w, "print result: %s \n", result)   //prints nil
    fmt.Fprintf(w, "print error one: %v \n", errOne) // prints nil
    fmt.Fprintf(w, "print error two: %s \n", errTwo) // prints error

}

The error says there is no service called fooService.FooService which is true because the dns name for the service I am calling is called foo-service. However it is the exact same setup for my other services that use gRPC and work fine. Also my proto files are correctly configured so that is not an issue.

server I am calling:

 func main() {

    lis, err := net.Listen("tcp", ":10006")
    if err != nil {
        log.Fatalf("failed to listen: %v", err)
    }

    grpcServer := grpc.NewServer()
    newServer := &RedisGatewayServer{}
    rs.RegisterRedisGatewayServer(grpcServer, newServer)

    if err := grpcServer.Serve(lis); err != nil {
        log.Fatalf("failed to serve: %v", err)
    }

}

The function I am trying to access from client:

func (s *RedisGatewayServer) GetData(ctx context.Context, in *rs.KeyRequest)(*rs.KeyRequest, error) {

     return in, nil
}

My docker and yaml files are all correct also with the right naming and ports.

1
When it says “unknown service fooService.FooService,” what I think it is saying is that there is no grpc service Registered with that grpc path. Are you sure you registered a service with the exact same path?dolan
@dolan After I complied my .proto file it gave me a .pb.go file which specifies fooService.FooService as the service name. This is the same as the other .pb.go files I have for different services that are working fine. I implemented the code the exact same way also. The only thing different with this setup is the fact I have exposed a port on the service the grpc client code is running on. Is there a way I can manually add the service or check against the path? Not too sure how I would go about doing this.MATT SHALLOW
unknown service fooServcie.FooService is that a typo?Hana Alaydrus
@HanaAlaydrus yes sorry.MATT SHALLOW
As @dolan mentioned, the error message indicates the service is not registered on the server. Double check that the service is registered on the server? Also, you mentioned load balancer, maybe also make sure the request is sent to the correct server?menghanl

1 Answers

1
votes

thanks @dolan's for the comment, it solved the problem.

Basically we have to make sure, the method value should be same in both server and client (you can even copy the method name from the pb.go file generated from server side)

func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...CallOption) error {

this invoke function will be there inside all the methods which you have implemented in gRPC service.