1
votes

I'm looking for the following timeout options on the client side. In other words, how do you set an upper limit on these times?

  1. Time it takes to establish a socket connection.
  2. Time it takes to receive the first response packet.
  3. Time it takes to receive the last response packet.

There's a deadline documented, but it's not clear to me which of the above three corresponds to it.

I've seen this and this post, but none of them answer my question.

1

1 Answers

1
votes

I am a bit confused about the question. Question is about setting timeout options, and the bullet points are about metrics. My answer is based on the question. assuming #1 is how to set connection timeout, you can configure it via NettyChannelBuilder.

In NettyChannelBuilder (most common), you can pass channel options via NettyChannelBuilder#withOption. You can check known channel options in netty ChannelOption.

    ManagedChannel channel = NettyChannelBuilder
        .forTarget(target)
        // For other channel options see linked javadoc above
        .withOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int) TimeUnit.SECONDS.toMillis(5))
        .build();

#2 and #3 needs more clarifications, but sounds like it is related to deadline.