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 < ssachinbharad...@gmail.com> 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 grpc-io+unsubscr...@googlegroups.com. > 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 mjp...@indeed.com 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 grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAHa8AVSGvakLke_a5Yudr-GJZGMcsuVsT7TJdrwt-1wHRbvgvQ%40mail.gmail.com.