0

I have implemented a subscribe pattern RPC with gRPC (

  rpc SubscribeX(SubscribeXRequest) returns (stream X)

) using grpc-go. In the client, I want to resubscribe if there is a problem with the connection. I'm not sure if I should use their backoff mechanism (now called ConnectParams) when creating the channel, or it wouldn't let me resubscribe when it reconnects. Is there a way to listen on ClientConn state changes? A recommended way of implementing it? Or an example for a similar usage pattern?

Reza Mohammadi
  • 645
  • 5
  • 13

1 Answers1

0

The backoff config controls connection backoff, not directly on the RPCs. In most cases, you don't want to change that (if there's a problem connecting, retrying more often won't help).

To retry the RPC, take a look at this: https://github.com/grpc/grpc-go/blob/master/examples/features/retry/README.md

Or if you want to blindly retry them, make the RPCs WaitForReady(true) and wrap them in a for loop.

menghanl
  • 751
  • 6
  • 7