grpc / grpc-java

The Java gRPC implementation. HTTP/2 based RPC
https://grpc.io/docs/languages/java/
Apache License 2.0
11.39k stars 3.83k forks source link

ManagedChannelImpl.getState(boolean requestConnection) always return IDLE #11327

Closed kevinw66 closed 3 months ago

kevinw66 commented 3 months ago

I'm using channel.getState(true) to check if my connection in the channel is correct, but no matter which address I use it will always return IDLE. My gRPC version: 1.63.0 And here is my test code:

public static void main(String[] args) throws Exception {
    ManagedChannel channel = ManagedChannelBuilder.forAddress("177.177.177.177", 1717)
            .usePlaintext()
            .build();
    ConnectivityState state = channel.getState(true);
    System.out.println(state);
    Thread.sleep(10000);
    System.out.println(state);
}