Sorry for the late answer.

As you can said, it can be checked by sending a simple test rpc. Or you can 
do by monitoring the state of channel via WaitForStateChange method after 
making the channel start to connect by calling channel->GetState(true) .

On Thursday, October 22, 2020 at 12:27:37 PM UTC-7 christo...@gmail.com 
wrote:

> How can I check if the RPC client actually made a successfull connection 
> to the RPC server when I create the channel and stub?
>
> I want to be able to throw an exception or signal if the connection 
> failed. I am not sure what method qualifies as an "operation" to try here. 
> I don't want to make any of the RPC calls that we defined, as they all have 
> effects that will occur....unless the only option is to go implement some 
> "Hi I am here" RPC method, but that seems silly, no?
> void ChatSyncClient::connect(QUrl const& endpoint) 
> { 
>      disconnect(); 
>      // TODO - How do we tell if this fails? 
>      // The comments say a lame channel will be returned, where all 
> operations fail 
>      // How are we suppose to check right here rather than later? 
>      auto channel =    
> ::grpc::CreateChannel(endpoint.toString().toStdString(), 
> ::grpc::InsecureChannelCredentials()); 
>      m_stub = std::make_unique<chat_sync::Chat::Stub>(channel); 
>      emit signalOnConnected(); 
> }
>

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/adc02a9c-5360-444f-b5cb-31c137c0de21n%40googlegroups.com.

Reply via email to