Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemcachedClient doesn't autodetect correct client mode when connection factory client mode is set to 'Unset' #42

Open
barrycburton opened this issue Aug 28, 2024 · 0 comments

Comments

@barrycburton
Copy link

I'm using the following code to set up a memcached client to connect to a multi-node elasticache cluster. The URL_PROPERTY is set to a configure url which contains ".cfg." I explicitly set the client mode to 'Unset' which based on MemcachedClient.java looks like it should trigger the determineClientMode logic. But for some reason it doesn't and the client always ends up set to Static mode and only uses a single node in the cluster. If I instead explicitly set the connection factory client mode to Dynamic it works as expected and correctly detects and uses all nodes in the cluster.

  ConnectionFactoryBuilder connectionFactoryBuilder = new ConnectionFactoryBuilder(new KetamaConnectionFactory());
  if (Boolean.parseBoolean(RuntimeProperties.getProperty(CACHE_PROVIDER_MEMCACHED_USE_SSL_PROPERTY))) {
    // Build SSLContext
    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    tmf.init((KeyStore)null);
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, tmf.getTrustManagers(), null);
    // Create the client in TLS mode
    connectionFactoryBuilder.setSSLContext(sslContext);
    connectionFactoryBuilder.setSkipTlsHostnameVerification(true);
  }
  connectionFactoryBuilder.setClientMode(ClientMode.Unset);
  cache = new MemcachedClient(connectionFactoryBuilder.build(), AddrUtil.getAddresses(
        RuntimeProperties.getProperty(CACHE_PROVIDER_MEMCACHED_URL_PROPERTY)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant