Skip to main content
Version: 2.x

HTTP implementations

By default the AWS Java SDK uses netty under the hood to make the HTTP client calls. zio-aws defines the http client as a layer (HttpClient) that has to be provided to the AWS configuration layer.

Currently the following implementations can be used:

  • zio-aws-netty contains the default netty implementation packed as a layer
  • zio-aws-akka-http is based on Matthias Lüneberg's aws-spi-akka-http library
  • zio-aws-http4s is an implementation on top of http4s

Netty

The default HTTP implementation in the AWS Java SDK is Netty. To use it with the default settings, use the netty.default layer to provide the HttpClient for the AwsConfig layer. It is also possible to customize the NettyNioAsyncHttpClient directly by manipulation it's Builder, by using the netty.customized(customization) layer.

The recommended way for configuration is to use the zio-config support:

def configured(
tlsKeyManagersProvider: Option[TlsKeyManagersProvider] = None,
tlsTrustManagersProvider: Option[TlsTrustManagersProvider] = None
): ZLayer[ZConfig[NettyClientConfig], Throwable, HttpClient]

Everything except the TLS key and trust managers are described by the zio-config provided NettyClientConfig data structure. See the following table for all the options:

Configuration Details

FieldNameFormatDescriptionSources
all-of

Field Descriptions

FieldNameFormatDescriptionSources
maxConcurrencyprimitivevalue of type int, default value: 50, Maximum number of allowed concurrent requests
maxPendingConnectionAcquiresprimitivevalue of type int, default value: 10000, The maximum number of pending acquires allowed
readTimeoutprimitivevalue of type duration, default value: PT30S, The amount of time to wait for a read on a socket
writeTimeoutprimitivevalue of type duration, default value: PT30S, The amount of time to wait for a write on a socket
connectionTimeoutprimitivevalue of type duration, default value: PT2S, The amount of time to wait when initially establishing a connection before giving up
connectionAcquisitionTimeoutprimitivevalue of type duration, default value: PT10S, The amount of time to wait when acquiring a connection from the pool before giving up
connectionTimeToLiveprimitivevalue of type duration, default value: PT0S, The maximum amount of time that a connection should be allowed to remain open, regardless of usage frequency
connectionMaxIdleTimeprimitivevalue of type duration, default value: PT5S, Maximum amount of time that a connection should be allowed to remain open while idle
useIdleConnectionReaperprimitivevalue of type boolean, default value: true, If true, the idle connections in the pool should be closed
protocolprimitivevalue of type string, default value: Dual, HTTP/1.1 or HTTP/2 or Dual
channelOptionsall-ofdefault value: NettyChannelOptions(Vector()), Custom Netty channel options
sslProviderprimitivevalue of type string, optional value, The SSL provider to be used
proxyall-ofoptional value, Proxy configuration
http2all-ofoptional value, HTTP/2 specific options

channelOptions

FieldNameFormatDescriptionSources
SO_BROADCASTprimitivevalue of type boolean, optional value, Allow transmission of broadcast datagrams
SO_KEEPALIVEprimitivevalue of type boolean, optional value, Keep connection alive
SO_SNDBUFprimitivevalue of type int, optional value, The size of the socket send buffer
SO_RCVBUFprimitivevalue of type int, optional value, The size of the socket receive buffer
SO_REUSEADDRprimitivevalue of type boolean, optional value, Re-use address
SO_LINGERprimitivevalue of type int, optional value, Linger on close if data is present
IP_TOSprimitivevalue of type int, optional value, The ToS octet in the IP header
IP_MULTICAST_IFprimitivevalue of type string, optional value, The network interface's name for IP multicast datagrams
IP_MULTICAST_TTLprimitivevalue of type int, optional value, The time-to-live for IP multicast datagrams
IP_MULTICAST_LOOPprimitivevalue of type boolean, optional value, Loopback for IP multicast datagrams
TCP_NODELAYprimitivevalue of type boolean, optional value, Disable the Nagle algorithm
CONNECT_TIMEOUT_MILLISprimitivevalue of type duration, optional value, Connect timeout
WRITE_SPIN_COUNTprimitivevalue of type int, optional value, Write spin count
ALLOW_HALF_CLOSUREprimitivevalue of type boolean, optional value, Allow half closure
AUTO_READprimitivevalue of type boolean, optional value, Auto read
AUTO_CLOSEprimitivevalue of type boolean, optional value, Auto close
SINGLE_EVENTEXECUTOR_PER_GROUPprimitivevalue of type boolean, optional value, Single event executor per group

proxy

FieldNameFormatDescriptionSources
schemeprimitivevalue of type string, default value: Http, The proxy scheme
hostprimitivevalue of type string, Hostname of the proxy
portprimitivevalue of type int, Port of the proxy
nonProxyHostslistvalue of type string, default value: Set(), Hosts that should not be proxied

http2

FieldNameFormatDescriptionSources
maxStreamsprimitivevalue of type long, Max number of concurrent streams per connection
initialWindowSizeprimitivevalue of type int, Initial window size of a stream
healthCheckPingPeriodprimitivevalue of type duration, default value: PT5S, The period that the Netty client will send PING frames to the remote endpoint

Akka HTTP

The Akka HTTP implementation can be chosen by using the akkahttp.client() layer for providing HttpClient to AwsConfig. This implementation uses the standard akka-http settings from the application's Lightbend config, it is not described with zio-config descriptors.

http4s

Another alternative is the http4s client. To use the default settings, provide the http4s.default layer to AwsConfig. Customization by manipulating the builder is also possible by http4s.customized(customization). And similarly to the Netty client, configuration is also possible via zio-config:

Configuration Details

FieldNameFormatDescriptionSources
all-of

Field Descriptions

FieldNameFormatDescriptionSources
responseHeaderTimeoutprimitivevalue of type duration, default value: Duration.Inf, Timeout for receiving the header part of the response
idleTimeoutprimitivevalue of type duration, default value: 1 minute, Timeout for client connection staying idle
requestTimeoutprimitivevalue of type duration, default value: 45 seconds, Timeout for the whole request
connectTimeoutprimitivevalue of type duration, default value: 10 seconds, Timeout for connecting to the server
userAgentprimitivevalue of type string, default value: User-Agent(http4s-blaze/3.0.2,List()), User-Agent header sent by the client
maxTotalConnectionsprimitivevalue of type int, default value: 10, Maximum number of parallel connections
maxWaitQueueLimitprimitivevalue of type int, default value: 256, Maximum number of requests in queue
checkEndpointIdentificationprimitivevalue of type boolean, default value: true, Check https identity
maxResponseLineSizeprimitivevalue of type int, default value: 4096, Maximum line length of headers in response
maxHeaderLengthprimitivevalue of type int, default value: 40960, Maximum total length of the response headers
maxChunkSizeprimitivevalue of type int, default value: 2147483647, Maximum chunk size
chunkBufferMaxSizeprimitivevalue of type int, default value: 1048576, Maximum size of the chunk buffer
parserModeprimitivevalue of type string, default value: Strict, Parser mode, strict or lenient
bufferSizeprimitivevalue of type int, default value: 8192, Buffer size
channelOptionsall-ofdefault value: ChannelOptions(Vector(OptionValue(TCP_NODELAY,true))), Collection of socket options

channelOptions

FieldNameFormatDescriptionSources
SO_BROADCASTprimitivevalue of type boolean, optional value, Allow transmission of broadcast datagrams
SO_KEEPALIVEprimitivevalue of type boolean, optional value, Keep connection alive
SO_SNDBUFprimitivevalue of type int, optional value, The size of the socket send buffer
SO_RCVBUFprimitivevalue of type int, optional value, The size of the socket receive buffer
SO_REUSEADDRprimitivevalue of type boolean, optional value, Re-use address
SO_LINGERprimitivevalue of type int, optional value, Linger on close if data is present
IP_TOSprimitivevalue of type int, optional value, The ToS octet in the IP header
IP_MULTICAST_IFprimitivevalue of type string, optional value, The network interface's name for IP multicast datagrams
IP_MULTICAST_TTLprimitivevalue of type int, optional value, The time-to-live for IP multicast datagrams
IP_MULTICAST_LOOPprimitivevalue of type boolean, optional value, Loopback for IP multicast datagrams
TCP_NODELAYprimitivevalue of type boolean, optional value, Disable the Nagle algorithm