question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
voidzcycommented, May 16, 2019

@dshylov

You service name still does not look right. It should be the full name of the service, which is PROTO_FILENAME.SERVICE_NAME. For example, for the helloworld example, it should be helloworld.Greeter. I’ve tried with your retry config, it worked for me by using the helloworld example.

0reactions
dshylovcommented, May 19, 2019

Thanks for the explanation @voidzcy I will close this issue since the original problem was resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transient fault handling with gRPC retries - Microsoft Learn
Configures a retry policy. This policy instructs clients to automatically retry gRPC calls that fail with the status code Unavailable . ...
Read more >
gRPC A6: Retries - Google Groups
The retry attempt or hedged RPC will be re-resolved through the load-balancer, so it's up to the service owner to ensure that this...
Read more >
grpc/grpc - Gitter
I'm trying to write a grpc-java client that can store failed/canceled ... If I had a retry mechanism I think it would solve...
Read more >
RPC semantics of gRPC - Stack Overflow
gRPC provides at-most-once guarantee by default. Things like retries and similar can change that, but they are opt-in.
Read more >
Migration to gRPC client - EventStoreDB Documentation
The gRPC client handles reconnections internally. But contrary to the TCP client, it does not have built-in retries for failed operations. It ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found