jetcd: Detecting connection errors

Hi!

What is the correct way to do KV requests with a timeout? The client seems to retry forever (jetcd 0.5.10). My code looks like this:

Client etcd = Client.builder()
        .endpoints("http://127.0.0.1:2379")
        .connectTimeout(Duration.ofSeconds(1))
        .build();

CountDownLatch countDownLatch = new CountDownLatch(1);
etcd.getKVClient()
        .get(ByteSequence.from("/x", StandardCharsets.UTF_8))
        .whenComplete((response, throwable) -> {
            if (throwable != null) {
                throwable.printStackTrace();
            }

            System.out.println("response = " + response);
            countDownLatch.countDown();
        });

countDownLatch.await();
System.out.println("done");

If I run this code without ectd running, it will never terminate. I’ve tried different retry options to the client builder but I can’t get it to work.

Thanks, Anton

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I’ll do it today or tomorrow

On Thu, 28 Oct 2021 at 11:32, Anton Lindström @.***> wrote:

Hi!

Any updates on when this can be released? 😃

Thanks Anton

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/etcd-io/jetcd/issues/970#issuecomment-953676346, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOIJBMGVS4URTWI637ZEE3UJERFDANCNFSM5DDZ4YJA .

Luca Burgazzoli

I’m waiting for feedback on another pr, then I can do a release

I’ve updated #971 with a fix!