If you're using the async completion queue based C++ API, then I believe you can use the AsyncNotifyWhenDone <https://github.com/grpc/grpc/blob/6dc8024bb44435579a79f2484687c91e7d34e55e/include/grpcpp/impl/codegen/server_context_impl.h#L281> API for this. See surrounding comments in the linked code for more details.
On Wednesday, August 12, 2020 at 8:00:42 AM UTC-7 [email protected] wrote: > Health Checking Protocol: > https://grpc.github.io/grpc/cpp/md_doc_health-checking.html > > On Wed, Aug 12, 2020 at 9:59 AM Mya Pitzeruse <[email protected]> wrote: > >> Let's start with the server case because it's a bit easier. gRPC provides >> some built in healthchecking capabilities. Clients watch server health. >> When a server goes unhealthy, clients remove them from the pool. >> >> gRPC doesn't necessarily surface connection primitives to your server >> side so it's probably not easy to get at the same information for clients. >> On the other hand, you could use something like a long lived bidi-streaming >> API to "simulate" a connection with a backend. You'll need to handle >> network disconnects, but you could use that approach to do some cleanup. >> While it's not C++, here's a go example where a server side streaming API >> cleans >> up a subscription >> <https://github.com/mjpitz/paxos/blob/main/internal/server/acceptor.go#L106-L110> >> >> when the client is disconnected. >> >> >> On Wed, Aug 12, 2020 at 5:57 AM Sachin Bharadwaj S <[email protected]> >> wrote: >> >>> I have implemented a gRPC server application and multiple clients can >>> connect to it and call RPCs. >>> >>> In the cases of client disconnection or client restarts, I would want to >>> know which client got disconnected so that I can do some cleanup >>> corresponding to that client. >>> >>> Similarly, if the server goes down, how can the client get notified? >>> >>> Does gRPC c++ stack provides a notification/callback to the application? >>> If not, what is the best way to handle the connection termination on either >>> side? >>> >>> -- >>> 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/ab98d62c-231b-4e5b-bc0e-6519a9d0320ao%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/grpc-io/ab98d62c-231b-4e5b-bc0e-6519a9d0320ao%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> >> Mya Pitzeruse >> >> Principal Software Engineer - Service Infrastructure >> >> Gender Pronouns: She, Her, Hers >> >> [email protected] >> >> >> Indeed - We help people get jobs. >> >> Indeed.com <http://www.indeed.com/> >> >> Facebook <http://www.facebook.com/indeed> | Twitter >> <http://www.twitter.com/indeed> | Instagram >> <http://www.instagram.com/indeedworks> >> > > > -- > > Mya Pitzeruse > > Principal Software Engineer - Service Infrastructure > > Gender Pronouns: She, Her, Hers > > [email protected] > > > Indeed - We help people get jobs. > > Indeed.com <http://www.indeed.com/> > > Facebook <http://www.facebook.com/indeed> | Twitter > <http://www.twitter.com/indeed> | Instagram > <http://www.instagram.com/indeedworks> > -- 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/3141465f-6956-47d3-8a62-dc8ed81b92aen%40googlegroups.com.
