我的gRPC Java客户端连接到带有套接字和NIO的服务器Java NIO请求的客户端到服务器gRPC但服务器没有响应。
我的客户gRPC代码:
private final ManagedChannel channel;
private final MyServiceProviderGrpc.MyServiceProviderBlockingStub blockingStub;
private final MyServiceProviderGrpc.MyServiceProviderStub asyncStub;
public ClientGrpc(String host, int port)
{
this(ManagedChannelBuilder.forAddress(host, port).usePlaintext(true));
}
ClientGrpc(ManagedChannelBuilder<?> channelBuilder)
{
channel = channelBuilder.build();
blockingStub = MyServiceProviderGrpc.newBlockingStub(channel);
asyncStub = MyServiceProviderGrpc.newStub(channel); }
public void greet(String name) {
logger.info("Will try to greet " + name + " ...");
TemperatureRequest request = TemperatureRequest.newBuilder().setQuestion(name).build();
TemperatureResponse response;
try
{
response = blockingStub.getTemperature(request);
} catch (StatusRuntimeException e)
{
logger.info("RPC failed: {0}"+ e.getStatus());
return;
}
logger.info("Greeting: " + response.getAnswer()); }
ClientGrpc clients = new ClientGrpc("localhost",4321);
clients.greet("bap");
我在NIO收到一条消息:
PRI * HTTP / 2.0
SM