We run a Gradle build inside a ECS container in Amazon. The build is quite a long one ~ dozens of minutes. Sometimes, after a while, the build fails with
Execution failed for task ':tests:tests-jvm:compileTestKotlin'.
> Could not resolve all files for configuration ':tests:tests-jvm:testCompileClasspath'.
> Could not download aws-java-sdk-sqs-1.11.521.jar (com.amazonaws:aws-java-sdk-sqs:1.11.521)
> Could not get resource 'https://repo.maven.apache.org/maven2/com/amazonaws/aws-java-sdk-sqs/1.11.521/aws-java-sdk-sqs-1.11.521.jar'.
> Could not GET 'https://repo.maven.apache.org/maven2/com/amazonaws/aws-java-sdk-sqs/1.11.521/aws-java-sdk-sqs-1.11.521.jar'.
> Connection reset
After a bit of research, we found out that such http requests go through AWS NAT that resets http connections that last longer than 350 seconds. Then, we made a guess that Gradle doesn’t keep http connections alive between usages or the keep-alive period is longer than 350 seconds. Is it correct? Is it possible to setup the keep-alive timeout for the Gradle connections?
P.S.1:
Seems TCP keep alive can’t be set on the apache client level, and we have to use OS level settings
sudo sysctl -w net.ipv4.tcp_keepalive_time=60
sudo sysctl -w net.ipv4.tcp_keepalive_intvl=60
sudo sysctl -w net.ipv4.tcp_keepalive_probes=10