Hi,

You would need to call WaitForStateChange to wait for the connectivity 
state to actually change. A sample way to do this would be -

while ((state = channel->GetState(/*try_to_connect=*/true)) != 
GRPC_CHANNEL_READY) { 
  if (!channel->WaitForStateChange(state, deadline)) {
    // deadline has expired
  } 
}

On Monday, 21 October 2019 00:36:56 UTC-7, Haripriya wrote:
>
> Hi,
>
>
> As per the GRPC doc  (
> https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md
> )
>
> All gRPC libraries will expose a channel-level API method to poll the 
> current state of a channel. In C++, this method is called GetState and 
> returns an enum for one of the five legal states. It also accepts a boolean 
> try_to_connect to transition to CONNECTING if the channel is currently 
> IDLE. The boolean should act as if an RPC occurred, so it should also reset 
> IDLE_TIMEOUT.
>
> grpc_connectivity_state GetState(bool try_to_connect);
>
>
>
> However, even after calling multiple times getState(true) does not move 
> the GRPC channel state from GRPC_CHANNEL_IDLE to GRPC_CHANNEL_READY state.
> Also how to simulate this behavior? (i.e Changing the GRPC channel state 
> for debugging purpose)
>
> I would appreciate it if anyone could help me out in this regard.
>
> Thank you in advance.
> Regards,
> Haripriya
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/cd8638c0-c7b7-4222-a2b2-ed53ff1a5cbe%40googlegroups.com.

Reply via email to