LambdaClient - Run Time Exception: Connection pool shut down

66 views Asked by At

I'm getting a Connection pool shut down exception when using a LambdaClient. The LambdaClient is created each time I need to call the lambda as the config can change.

After what appears to be a random number of calls it starts failing and throwing a Connection pool shut down exception. It will then fail with every subsequent call and is only resolved by restarting the service.

It's strange as we're creating the LambdaClient each time and it should call .close() as it's using a try-with-resource statement. It's as though there is something stored globally that is being shut down which means any new LambdaClients will fail to make a connection.

The exception doesn't give any more information on this including line numbers.

try (LambdaClient client = LambdaClient.builder()
        .region(region)
        .credentialsProvider(DefaultCredentialsProvider.create())
        .overrideConfiguration(
                builder -> builder.apiCallTimeout(Duration.ofSeconds(118))
                        .apiCallAttemptTimeout(Duration.ofSeconds(118))
                        .retryPolicy(RetryPolicy.none()))
        .httpClientBuilder(ApacheHttpClient.builder()
                .maxConnections(10)
                .socketTimeout(Duration.ofSeconds(130))
                .connectionTimeout(Duration.ofSeconds(130))
        )
        .build()) {
    res = client.invoke(request);
    lambdaResponse = res.payload().asUtf8String();
}

Why is this error thrown?

0

There are 0 answers