Interface NettyNioAsyncHttpClient.Builder
-
- All Superinterfaces:
Buildable
,SdkAsyncHttpClient.Builder<NettyNioAsyncHttpClient.Builder>
,SdkBuilder<NettyNioAsyncHttpClient.Builder,SdkAsyncHttpClient>
- Enclosing class:
- NettyNioAsyncHttpClient
public static interface NettyNioAsyncHttpClient.Builder extends SdkAsyncHttpClient.Builder<NettyNioAsyncHttpClient.Builder>
Builder that allows configuration of the Netty NIO HTTP implementation. UseNettyNioAsyncHttpClient.builder()
to configure and construct a Netty HTTP client.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description NettyNioAsyncHttpClient.Builder
connectionAcquisitionTimeout(Duration connectionAcquisitionTimeout)
The amount of time to wait when acquiring a connection from the pool before giving up and timing out.NettyNioAsyncHttpClient.Builder
connectionMaxIdleTime(Duration maxIdleConnectionTimeout)
Configure the maximum amount of time that a connection should be allowed to remain open while idle.NettyNioAsyncHttpClient.Builder
connectionTimeout(Duration timeout)
The amount of time to wait when initially establishing a connection before giving up and timing out.NettyNioAsyncHttpClient.Builder
connectionTimeToLive(Duration connectionTimeToLive)
The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency.NettyNioAsyncHttpClient.Builder
eventLoopGroup(SdkEventLoopGroup eventLoopGroup)
Sets theSdkEventLoopGroup
to use for the Netty HTTP client.NettyNioAsyncHttpClient.Builder
eventLoopGroupBuilder(SdkEventLoopGroup.Builder eventLoopGroupBuilder)
Sets theSdkEventLoopGroup.Builder
which will be used to create theSdkEventLoopGroup
for the Netty HTTP client.NettyNioAsyncHttpClient.Builder
http2Configuration(Consumer<Http2Configuration.Builder> http2ConfigurationBuilderConsumer)
Set the HTTP/2 specific configuration for this client.NettyNioAsyncHttpClient.Builder
http2Configuration(Http2Configuration http2Configuration)
Set the HTTP/2 specific configuration for this client.NettyNioAsyncHttpClient.Builder
maxConcurrency(Integer maxConcurrency)
Maximum number of allowed concurrent requests.NettyNioAsyncHttpClient.Builder
maxHttp2Streams(Integer maxHttp2Streams)
Deprecated.Usehttp2Configuration(Http2Configuration)
along withHttp2Configuration.Builder.maxStreams(Long)
instead.NettyNioAsyncHttpClient.Builder
maxPendingConnectionAcquires(Integer maxPendingAcquires)
The maximum number of pending acquires allowed.NettyNioAsyncHttpClient.Builder
protocol(Protocol protocol)
Sets the HTTP protocol to use (i.e.NettyNioAsyncHttpClient.Builder
proxyConfiguration(ProxyConfiguration proxyConfiguration)
Set the proxy configuration for this client.NettyNioAsyncHttpClient.Builder
putChannelOption(io.netty.channel.ChannelOption channelOption, Object value)
Configures additionalChannelOption
which will be used to create Netty Http client.NettyNioAsyncHttpClient.Builder
readTimeout(Duration readTimeout)
The amount of time to wait for a read on a socket before an exception is thrown.NettyNioAsyncHttpClient.Builder
sslProvider(io.netty.handler.ssl.SslProvider sslProvider)
Sets theSslProvider
to be used in the Netty client.NettyNioAsyncHttpClient.Builder
tcpKeepAlive(Boolean keepConnectionAlive)
Configure whether to enable or disable TCP KeepAlive.NettyNioAsyncHttpClient.Builder
tlsKeyManagersProvider(TlsKeyManagersProvider keyManagersProvider)
Set theTlsKeyManagersProvider
for this client.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.NettyNioAsyncHttpClient.Builder
tlsTrustManagersProvider(TlsTrustManagersProvider trustManagersProvider)
Configure theTlsTrustManagersProvider
that will provide theTrustManager
s to use when constructing the SSL context.NettyNioAsyncHttpClient.Builder
useIdleConnectionReaper(Boolean useConnectionReaper)
Configure whether the idle connections in the connection pool should be closed.NettyNioAsyncHttpClient.Builder
useNonBlockingDnsResolver(Boolean useNonBlockingDnsResolver)
Configure whether to use a non-blocking dns resolver or not.NettyNioAsyncHttpClient.Builder
writeTimeout(Duration writeTimeout)
The amount of time to wait for a write on a socket before an exception is thrown.-
Methods inherited from interface software.amazon.awssdk.http.async.SdkAsyncHttpClient.Builder
build, buildWithDefaults
-
Methods inherited from interface software.amazon.awssdk.utils.builder.SdkBuilder
applyMutation
-
-
-
-
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
) 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 (seemaxPendingConnectionAcquires(Integer)
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. SpecifyDuration.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. SpecifyDuration.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. UnlikereadTimeout(Duration)
andwriteTimeout(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.
-
connectionMaxIdleTime
NettyNioAsyncHttpClient.Builder connectionMaxIdleTime(Duration maxIdleConnectionTimeout)
Configure the maximum amount of time that a connection should be allowed to remain open while idle. Currently has no effect ifuseIdleConnectionReaper(Boolean)
is false. UnlikereadTimeout(Duration)
andwriteTimeout(Duration)
, this will never close a connection that is currently in use, so long-lived connections may remain open longer than this time.
-
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 durationBy 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 theSdkEventLoopGroup
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 anEventLoopGroup
is by using theSdkEventLoopGroup.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 theEventLoopGroup
when the HTTP client is closed. SeeEventExecutorGroup.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 useeventLoopGroupBuilder(SdkEventLoopGroup.Builder)
as the SDK will handle its cleanup when the HTTP client is closed.- Parameters:
eventLoopGroup
- NettySdkEventLoopGroup
to use.- Returns:
- This builder for method chaining.
- See Also:
SdkEventLoopGroup
-
eventLoopGroupBuilder
NettyNioAsyncHttpClient.Builder eventLoopGroupBuilder(SdkEventLoopGroup.Builder eventLoopGroupBuilder)
Sets theSdkEventLoopGroup.Builder
which will be used to create theSdkEventLoopGroup
for the Netty HTTP client. This allows for custom configuration of the NettyEventLoopGroup
.The
EventLoopGroup
created by the builder is managed by the SDK and will be shutdown when the HTTP client is closed.This is the preferred configuration method when you just want to customize the
EventLoopGroup
but not share it across multiple HTTP clients. If you do wish to share anEventLoopGroup
, seeeventLoopGroup(SdkEventLoopGroup)
- Parameters:
eventLoopGroupBuilder
-SdkEventLoopGroup.Builder
to use.- Returns:
- This builder for method chaining.
- See Also:
SdkEventLoopGroup.Builder
-
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 optionSocketOptions.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 additionalChannelOption
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 setvalue
- SeeChannelOption
to find the type of value for each option- Returns:
- This builder for method chaining.
-
maxHttp2Streams
NettyNioAsyncHttpClient.Builder maxHttp2Streams(Integer maxHttp2Streams)
Deprecated.Usehttp2Configuration(Http2Configuration)
along withHttp2Configuration.Builder.maxStreams(Long)
instead.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 theSslProvider
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()
-
tlsKeyManagersProvider
NettyNioAsyncHttpClient.Builder tlsKeyManagersProvider(TlsKeyManagersProvider keyManagersProvider)
Set theTlsKeyManagersProvider
for this client. TheKeyManager
s will be used by the client to authenticate itself with the remote server if necessary when establishing the TLS connection.If no provider is configured, the client will default to
SystemPropertyTlsKeyManagersProvider
. To disable any automatic resolution via the system properties, useTlsKeyManagersProvider.noneProvider()
.- Parameters:
keyManagersProvider
- TheTlsKeyManagersProvider
.- Returns:
- The builder for method chaining.
-
tlsTrustManagersProvider
NettyNioAsyncHttpClient.Builder tlsTrustManagersProvider(TlsTrustManagersProvider trustManagersProvider)
Configure theTlsTrustManagersProvider
that will provide theTrustManager
s to use when constructing the SSL context.- Parameters:
trustManagersProvider
- TheTlsKeyManagersProvider
.- Returns:
- The builder for method chaining.
-
http2Configuration
NettyNioAsyncHttpClient.Builder http2Configuration(Http2Configuration http2Configuration)
Set the HTTP/2 specific configuration for this client.Note:If
maxHttp2Streams(Integer)
andHttp2Configuration.maxStreams()
are both set, the value set usingmaxHttp2Streams(Integer)
takes precedence.- Parameters:
http2Configuration
- The HTTP/2 configuration object.- Returns:
- the builder for method chaining.
-
http2Configuration
NettyNioAsyncHttpClient.Builder http2Configuration(Consumer<Http2Configuration.Builder> http2ConfigurationBuilderConsumer)
Set the HTTP/2 specific configuration for this client.Note:If
maxHttp2Streams(Integer)
andHttp2Configuration.maxStreams()
are both set, the value set usingmaxHttp2Streams(Integer)
takes precedence.- Parameters:
http2ConfigurationBuilderConsumer
- The consumer of the HTTP/2 configuration builder object.- Returns:
- the builder for method chaining.
-
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
-
-