Search code examples
debugginggrpcgrpc-java

Issue with grpcdebug tool running on grpc-java server-client


I came across grpcdebug tool which is in go language. I'm running a Insecure grpc java server and client(server is serving on localhost:50051). I followed "compile from source" step for installation and ran health command grpcdebug localhost:50051 health, got this error message <Overall>: SERVICE_UNKNOWN and for grpcdebug localhost:50051 channelz channels command, got 2024/04/19 17:07:22 failed to fetch top channels: rpc error: code = Unimplemented desc = Method not found: grpc.channelz.v1.Channelz/GetTopChannels error message.

Questions:

  1. Do I have to make any code changes on my server(like add any service) and client. Do I have to implement those channelz methods (my thought is it would have been taken care by grpcdebug tool).
  2. Since the tool is in go, is it not compatible to run on java server and client. Is this the reason why Im getting above error messages.
  3. Is there any documentation to run grpcdebug tool for java grpc applications or any in-house tool which works for grpc-java.

Solution

  • code = Unimplemented desc = Method not found: grpc.channelz.v1.Channelz/GetTopChannels

    This error says you don't have the Channelz service available on your server (or the service is too old and doesn't support GetTopChannels; but that isn't likely the case here).

    The grpc-java debugging example adds it using the AdminInterface API, which adds Channelz but also CSDS if you are using xDS:

    import io.grpc.services.AdminInterface;
    
    final Server server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create())
        .addService(new HostnameGreeter(hostname))
        .addServices(AdminInterface.getStandardServices()) // the key add for enabling grpcdebug
    

    You can also add channelz directly instead:

    import io.grpc.protobuf.services.ChannelzService;
    
    final Server server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create())
        .addService(new HostnameGreeter(hostname))
        .addServices(ChannelzService.newInstance(100)) // the key add for enabling grpcdebug