Hi Sidhartha, So is there another way for applying timeouts on streaming APIs? specially in the given context? I basically want to solve the internet connection error for my code.
On Saturday, April 20, 2019 at 12:26:49 AM UTC+5:30, Sidhartha Thota wrote: > > If I am not wrong, clientContext cannot be applied for streaming APIs. > Thats what I saw from my experience. But I am happy to know if there is > solution for this. > > On Fri, Apr 19, 2019 at 6:28 AM 'Rohan Chawhan' via grpc.io < > [email protected] <javascript:>> wrote: > >> Hey All, >> >> I am using C++ to communicate with google speech api server. >> >> I am using the usual approach of setting a deadline for the clientcontext >> to handle timeout functionality. >> >> I have put the *deadlines *like: >> void SetContextDeadline(grpc::ClientContext *context, unsigned int >> user_defined_deadline){ >> context->set_deadline(std::chrono::system_clock::now() + >> std::chrono::seconds(user_defined_deadline)); >> } >> >> Now, this function is called whenever I want to set the deadline *from >> now(time)* >> >> *int main(){* >> auto creds = grpc::GoogleDefaultCredentials(); >> auto channel = grpc::CreateChannel("speech.googleapis.com", creds); >> std::unique_ptr<Speech::Stub> speech(Speech::NewStub(channel)); >> >> grpc::ClientContext context; >> >> // Set timeout of 8 seconds => also this is the timeout which I am not >> able to cancel to set new timer >> // Whenever it ends (after 8 seconds) my program is terminated >> SetContextDeadline(&context,8); >> auto streamer = speech->StreamingRecognize(&context); >> >> // The microphone thread writes the audio content. >> std::thread microphone_thread(&MicrophoneThreadMain, streamer.get(), >> file_path); >> // Read responses. >> StreamingRecognizeResponse response; >> while (streamer->Read(&response)) { // Returns false when no more to >> read. >> // Now I want to cancel the previous deadline to set this new >> deadline, everytime I enter this loop >> // I am seeing that this is setting the new deadline but the program >> still terminates at the older timeout >> SetContextDeadline(&context,8); >> >> // Dump the transcript of all the results. >> // Implementation of response display >> } >> } >> >> >> >> Thanks in advance for your help >> >> >> *Matrix Comsec Pvt. Ltd.* >> #394, GIDC Makarpura - 390010. Dist: Vadodara, Gujarat, India >> [image: Matrix Telecom | Security] <http://bit.ly/comsec-esignature> >> IP Video Surveillance | <http://bit.ly/IPVS-esginature>People Mobility >> Management | <http://bit.ly/cosec-esignature>Unified Communications >> <http://bit.ly/telecom-esignature> >> 1 Million+ Customers | 2,500+ Partners | 60+ Products | 50+ Countries >> *We put more in the box, so your business can think more out of the box.* >> [image: Facebook] <https://www.facebook.com/matrixcomsec> [image: >> linkedin] <http://www.linkedin.com/in/matrixcomsec> [image: twitter] >> <https://twitter.com/Matrix_ComSec> >> <https://www.linkedin.com/company/matrix-telecom-solutions/> [image: >> youtube] <https://www.youtube.com/user/MatrixComSec> >> >> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/grpc-io. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/grpc-io/d8e3fbb2-ef13-4c97-8ed3-57c1c58486c9%40googlegroups.com >> >> <https://groups.google.com/d/msgid/grpc-io/d8e3fbb2-ef13-4c97-8ed3-57c1c58486c9%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Thanks, > Sidhartha Thota. > -- Matrix Comsec Pvt. Ltd. #394, GIDC Makarpura - 390010. Dist: Vadodara, Gujarat, India <http://bit.ly/comsec-esignature> IP Video Surveillance | <http://bit.ly/IPVS-esginature>People Mobility Management | <http://bit.ly/cosec-esignature>Unified Communications <http://bit.ly/telecom-esignature> 1 Million+ Customers | 2,500+ Partners | 60+ Products | 50+ Countries We put more in the box, so your business can think more out of the box. <https://www.facebook.com/matrixcomsec> <http://www.linkedin.com/in/matrixcomsec> <https://twitter.com/Matrix_ComSec> <https://www.linkedin.com/company/matrix-telecom-solutions/> <https://www.youtube.com/user/MatrixComSec> -- 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 post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/5cfd3c40-19fe-40c5-967e-0f5ca12c68bf%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
