Hi Yash,
Thank you for replying.
Note - *Intermittently I do observe this behavior. *
Yes, "WaitForStateChange" is already been added but still, it does not move
to READY state..
bool connect = true;
grpc_connectivity_state channel_state = grpcChannel->GetState(connect);
const int trySeconds = 10;
const int tryInterval = 1;
int tryCnt = 0;
while (channel_state != GRPC_CHANNEL_READY) {
*grpcChannel->WaitForStateChange(*channel_state,
std::chrono::system_clock::now() + std::chrono::seconds(tryInterval));
channel_state = grpcChannel->GetState(connect);
if (++tryCnt > (trySeconds / tryInterval)) {
break;
}
}
Also as per the GRPC doc:
getState() --- "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" ===>
Does this mean it will trigger RPC?
How getState(true) is different/equivalent with the normal RPC call ?
Would sending the actual RPC call would help in moving the channel state
from IDLE to READY?
Thank you in advance.
-Regards,
Haripriya
On Friday, October 25, 2019 at 7:09:25 AM UTC+5:30, Yash Tibrewal wrote:
>
> 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/7435e449-4bd5-497f-8d67-49da31b67e39%40googlegroups.com.