Skip to content

Does gRPC retry mechanism work and if so, where am I wrong? #5724

Closed
@dshylov

Description

@dshylov

What version of gRPC are you using?

1.20

What did you expect to see?

I'm trying to figure out how to set up custom retry mechanism. After looking at A6-client-retries and searching through github/google I didn't find any real examples/explanations. So I think that I missed some notable thing.

So, I try to create a client connection with a retry mechanism. Like:

    Map<String, Object> retryPolicy = new HashMap<>();
    retryPolicy.put("maxAttempts", 5D);
    retryPolicy.put("initialBackoff", "10s");
    retryPolicy.put("maxBackoff", "30s");
    retryPolicy.put("backoffMultiplier", 2D);
    retryPolicy.put("retryableStatusCodes", Arrays.<Object>asList("UNAVAILABLE", "UNAUTHENTICATED"));
    Map<String, Object> methodConfig = new HashMap<>();
    Map<String, Object> name = new HashMap<>();
    name.put("service", "client");
    methodConfig.put("name", Collections.<Object>singletonList(name));
    methodConfig.put("retryPolicy", retryPolicy);
    Map<String, Object> serviceConfig = new HashMap<>();
    serviceConfig.put("methodConfig", Collections.<Object>singletonList(methodConfig));

    final NettyChannelBuilder channelBuilder = NettyChannelBuilder
        .forAddress(host, port)
        .enableRetry()
        .defaultServiceConfig(serviceConfig)
        .intercept(authInterceptor);

And client behavior doesn't change.
Could anybody get me an advice/example or move me in the right direction?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions