Interface NettyNioAsyncHttpClient.Builder

    • Method Detail

      • maxConcurrency

        NettyNioAsyncHttpClient.Builder maxConcurrency​(Integer maxConcurrency)
        Maximum number of allowed concurrent requests. For HTTP/1.1 this is the same as max connections. For HTTP/2 the number of connections that will be used depends on the max streams allowed per connection.

        If the maximum number of concurrent requests is exceeded they may be queued in the HTTP client (see maxPendingConnectionAcquires(Integer)

        ) and can cause increased latencies. If the client is overloaded enough such that the pending connection queue fills up, subsequent requests may be rejected or time out (see connectionAcquisitionTimeout(Duration)).
        Parameters:
        maxConcurrency - New value for max concurrency.
        Returns:
        This builder for method chaining.
      • maxPendingConnectionAcquires

        NettyNioAsyncHttpClient.Builder maxPendingConnectionAcquires​(Integer maxPendingAcquires)
        The maximum number of pending acquires allowed. Once this exceeds, acquire tries will be failed.
        Parameters:
        maxPendingAcquires - Max number of pending acquires
        Returns:
        This builder for method chaining.
      • readTimeout

        NettyNioAsyncHttpClient.Builder readTimeout​(Duration readTimeout)
        The amount of time to wait for a read on a socket before an exception is thrown. Specify Duration.ZERO to disable.
        Parameters:
        readTimeout - timeout duration
        Returns:
        this builder for method chaining.
      • writeTimeout

        NettyNioAsyncHttpClient.Builder writeTimeout​(Duration writeTimeout)
        The amount of time to wait for a write on a socket before an exception is thrown. Specify Duration.ZERO to disable.
        Parameters:
        writeTimeout - timeout duration
        Returns:
        this builder for method chaining.
      • connectionTimeout

        NettyNioAsyncHttpClient.Builder connectionTimeout​(Duration timeout)
        The amount of time to wait when initially establishing a connection before giving up and timing out.
        Parameters:
        timeout - the timeout duration
        Returns:
        this builder for method chaining.
      • connectionAcquisitionTimeout

        NettyNioAsyncHttpClient.Builder connectionAcquisitionTimeout​(Duration connectionAcquisitionTimeout)
        The amount of time to wait when acquiring a connection from the pool before giving up and timing out.
        Parameters:
        connectionAcquisitionTimeout - the timeout duration
        Returns:
        this builder for method chaining.
      • connectionTimeToLive

        NettyNioAsyncHttpClient.Builder connectionTimeToLive​(Duration connectionTimeToLive)
        The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency. Unlike readTimeout(Duration) and writeTimeout(Duration), this will never close a connection that is currently in use, so long-lived connections may remain open longer than this time. In particular, an HTTP/2 connection won't be closed as long as there is at least one stream active on the connection.
      • tlsNegotiationTimeout

        NettyNioAsyncHttpClient.Builder tlsNegotiationTimeout​(Duration tlsNegotiationTimeout)
        Configure the maximum amount of time that a TLS handshake is allowed to take from the time the CLIENT HELLO message is sent to the time the client and server have fully negotiated ciphers and exchanged keys.
        Parameters:
        tlsNegotiationTimeout - the timeout duration

        By default, it's 10 seconds.

        Returns:
        this builder for method chaining.
      • useIdleConnectionReaper

        NettyNioAsyncHttpClient.Builder useIdleConnectionReaper​(Boolean useConnectionReaper)
        Configure whether the idle connections in the connection pool should be closed.

        When enabled, connections left idling for longer than connectionMaxIdleTime(Duration) will be closed. This will not close connections currently in use. By default, this is enabled.

      • eventLoopGroup

        NettyNioAsyncHttpClient.Builder eventLoopGroup​(SdkEventLoopGroup eventLoopGroup)
        Sets the SdkEventLoopGroup to use for the Netty HTTP client. This event loop group may be shared across multiple HTTP clients for better resource and thread utilization. The preferred way to create an EventLoopGroup is by using the SdkEventLoopGroup.builder() method which will choose the optimal implementation per the platform.

        The EventLoopGroup MUST be closed by the caller when it is ready to be disposed. The SDK will not close the EventLoopGroup when the HTTP client is closed. See EventExecutorGroup.shutdownGracefully() to properly close the event loop group.

        This configuration method is only recommended when you wish to share an EventLoopGroup with multiple clients. If you do not need to share the group it is recommended to use eventLoopGroupBuilder(SdkEventLoopGroup.Builder) as the SDK will handle its cleanup when the HTTP client is closed.

        Parameters:
        eventLoopGroup - Netty SdkEventLoopGroup to use.
        Returns:
        This builder for method chaining.
        See Also:
        SdkEventLoopGroup
      • protocol

        NettyNioAsyncHttpClient.Builder protocol​(Protocol protocol)
        Sets the HTTP protocol to use (i.e. HTTP/1.1 or HTTP/2). Not all services support HTTP/2.
        Parameters:
        protocol - Protocol to use.
        Returns:
        This builder for method chaining.
      • tcpKeepAlive

        NettyNioAsyncHttpClient.Builder tcpKeepAlive​(Boolean keepConnectionAlive)
        Configure whether to enable or disable TCP KeepAlive. The configuration will be passed to the socket option SocketOptions.SO_KEEPALIVE.

        By default, this is disabled.

        When enabled, the actual KeepAlive mechanism is dependent on the Operating System and therefore additional TCP KeepAlive values (like timeout, number of packets, etc) must be configured via the Operating System (sysctl on Linux/Mac, and Registry values on Windows).

      • putChannelOption

        NettyNioAsyncHttpClient.Builder putChannelOption​(io.netty.channel.ChannelOption channelOption,
                                                         Object value)
        Configures additional ChannelOption which will be used to create Netty Http client. This allows custom configuration for Netty.

        If a ChannelOption was previously configured, the old value is replaced.

        Parameters:
        channelOption - ChannelOption to set
        value - See ChannelOption to find the type of value for each option
        Returns:
        This builder for method chaining.
      • maxHttp2Streams

        NettyNioAsyncHttpClient.Builder maxHttp2Streams​(Integer maxHttp2Streams)
        Sets the max number of concurrent streams for an HTTP/2 connection. This setting is only respected when the HTTP/2 protocol is used.

        Note that this cannot exceed the value of the MAX_CONCURRENT_STREAMS setting returned by the service. If it does the service setting is used instead.

        Parameters:
        maxHttp2Streams - Max concurrent HTTP/2 streams per connection.
        Returns:
        This builder for method chaining.
      • sslProvider

        NettyNioAsyncHttpClient.Builder sslProvider​(io.netty.handler.ssl.SslProvider sslProvider)
        Sets the SslProvider to be used in the Netty client.

        If not configured, SslContext.defaultClientProvider() will be used to determine the SslProvider.

        Note that you might need to add other dependencies if not using JDK's default Ssl Provider. See https://netty.io/wiki/requirements-for-4.x.html#transport-security-tls

        Parameters:
        sslProvider - the SslProvider
        Returns:
        the builder of the method chaining.
      • proxyConfiguration

        NettyNioAsyncHttpClient.Builder proxyConfiguration​(ProxyConfiguration proxyConfiguration)
        Set the proxy configuration for this client. The configured proxy will be used to proxy any HTTP request destined for any host that does not match any of the hosts in configured non proxy hosts.
        Parameters:
        proxyConfiguration - The proxy configuration.
        Returns:
        The builder for method chaining.
        See Also:
        ProxyConfiguration.nonProxyHosts()
      • useNonBlockingDnsResolver

        NettyNioAsyncHttpClient.Builder useNonBlockingDnsResolver​(Boolean useNonBlockingDnsResolver)
        Configure whether to use a non-blocking dns resolver or not. False by default, as netty's default dns resolver is blocking; it namely calls java.net.InetAddress.getByName.

        When enabled, a non-blocking dns resolver will be used instead, by modifying netty's bootstrap configuration. See https://netty.io/news/2016/05/26/4-1-0-Final.html