Search code examples
aws-java-sdkaws-java-sdk-2.x

Is there an equivalent of the socketTimeout configuration option for the AwsCrtHttpClient?


In the AWS Java SDKv2, the ApacheHttpClient and UrlConnectionHttpClient both have a socketTimeout configuration option:

socketTimeout(Duration socketTimeout)

The amount of time to wait for data to be transferred over an established, open connection before the connection is timed out.

But I don’t see this option on the AwsCrtHttpClient... is there an equivalent setting for the AwsCrtHttpClient?


Solution

  • This is the equivalent: https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/http/crt/ConnectionHealthConfiguration.Builder.html

    If you want to emulate the old socket timeout behavior, just set minimumThroughputInBps to 1 and minimumThroughputTimeout to whatever you want your socket timeout to be. However, you can also make this timeout logic more complex by using a different value for minimumThroughputInBps in which case it will only timeout the connection if the data being received is under the specified threshold.