Skip to content

Instantly share code, notes, and snippets.

@larkintuckerllc
Created December 21, 2025 11:53
Show Gist options
  • Select an option

  • Save larkintuckerllc/e6b6aee45050a7cccf2f8ddfae8fcd19 to your computer and use it in GitHub Desktop.

Select an option

Save larkintuckerllc/e6b6aee45050a7cccf2f8ddfae8fcd19 to your computer and use it in GitHub Desktop.
package com.example;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.StatusRuntimeException;
public class GreeterClient {
public static void main(String[] args) {
String host = "localhost";
int port = 50051;
ManagedChannel channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
GreeterGrpc.GreeterBlockingStub blockingStub = GreeterGrpc.newBlockingStub(channel);
HelloRequest request = HelloRequest.newBuilder().setName("World").build();
try {
HelloReply response = blockingStub.sayHello(request);
String message = response.getMessage();
System.out.println(message);
} catch (StatusRuntimeException e) {
System.err.println("RPC failed: " + e.getStatus());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment