AWS DaxServiceException - DAX Connection is getting expired after some time

565 Views Asked by At

I am using a kubernetes service account to pass the DAX role to the spring boot application which is connecting to DAX cluster. For about 40 minutes, the service is able to connect to DAX and retrieve the response from DynamoDB tables. However I am seeing below exception after sometime:

extendedStackTrace":"software.amazon.dax.exceptions.DaxServiceException: [4.23.31.33] Connection requires authentication (Service: null, Status Code: -1, Request ID: null)\n\tat software.amazon.dax.exceptions.DaxServiceException.pickException(DaxServiceException.java:177) ~[amazon-dax-client-2.0.1.jar!/:?]\n\tat software.amazon.dax.channel.StatusCodeHandler.channelRead(StatusCodeHandler.java:43) ~[amazon-dax-client-2.0.1.jar!/:?]\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379

"thrown":{"commonElementCount":0,"localizedMessage":"Unable to call cluster endpoint: No endpoints available","message":"Unable to call cluster endpoint: No endpoints available","name":"software.amazon.awssdk.core.exception.SdkClientException"

This is how I have created a DAX Client Configuration. It is a bean present in @Configuration annotated class

  @Bean
  public ClusterDaxClient clusterDaxClient() {

    LOG.info("Started Creating DAX Cluster Client");

    ClusterDaxClient clusterDaxClient = null;
    try {
      clusterDaxClient =
          ClusterDaxClient.builder().overrideConfiguration(setClientConfiguration()).build();

      LOG.info("DAX Client Created Successfully");
      return clusterDaxClient;

    } catch (IOException e) {
      LOG.error("Error while connecting to DAX Client : ", e);
    }
    
    return null;
  }

  private software.amazon.dax.Configuration setClientConfiguration() {
    AwsCredentialsProvider provider =
        StaticCredentialsProvider.create(
            WebIdentityTokenFileCredentialsProvider.create().resolveCredentials());

    return software.amazon.dax.Configuration.builder()
        .credentialsProvider(provider)
        .region(Region.of(awsRegion))
        .url(daxEndpoint)
        .build();
  }

NOTE: I have verified that DAX cluster is in same VPC as EKS with same subnets and also Inbound rules allowed on Port 9111 in DAX Security Group.

0

There are 0 best solutions below