I have a grpc c++ client which is listening for a stream of responses from server, I want it to listen forever for the responses, or before shutting down send some response to server. But the client is shutting down automatically after 15secs. I tried to set ClientContext::set_deadline but its not working. Here is my code:
ClientContext context;
// Connection timeout in seconds
unsigned int client_connection_timeout = 5000;
// Set timeout for API
std::chrono::system_clock::time_point deadline = std::chrono::system_clock::now() + std::chrono::seconds(client_connection_timeout);
context.set_deadline(deadline);
std::unique_ptr<ClientReader<Tap>> reader(stub_->STap(&context, tap_request));
while (reader->Read(&tap_reply)) {
std::cout<<"Response got from server: " << tap_reply.message() << " " << std::endl;
}
status = reader->Finish();
// Act upon its status.
if (status.ok()) {
std::cout << "rpc succeeded" << std::endl;
} else {
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
std::cout << "RPC failed" << std::endl;
}
Can someone please point out what I am doing wrong? Or what to add in code to stop it from timeout.
Aucun commentaire:
Enregistrer un commentaire