Illustration Image

Java Application unable to connect to Cassandra after cassandra pods gets restarted

I have deployed a Java application as a pod in a Kubernetes environment, as well as Cassandra with a 3-node cluster. I am using Cassandra service FQDN to connect to Cassandra. Due to the Cassandra pod restart, all its IPs got changed, and Cassandra client/java is still connecting to older IPs. Below error:

Error while opening new channel (ConnectionInitException: [s0|connecting...] Protocol initialization request, step 1 (STARTUP {CQL_VERSION=3.0.0, DRIVER_NAME=Apache Cassandra Java Driver, DRIVER_VERSION=4.18.0, CLIENT_ID=c6ddf75c-3ffd-433a-b6ee}): failed to send request (java.nio.channels.NotYetConnectedException))

How can I make java application(Using Java 17) connect to latest IPs though we connect through service FQDN?

Java version: 17, cassandra driver version: 4.18

Become part of our
growing community!
Welcome to Planet Cassandra, a community for Apache Cassandra®! We're a passionate and dedicated group of users, developers, and enthusiasts who are working together to make Cassandra the best it can be. Whether you're just getting started with Cassandra or you're an experienced user, there's a place for you in our community.
A dinosaur
Planet Cassandra is a service for the Apache Cassandra® user community to share with each other. From tutorials and guides, to discussions and updates, we're here to help you get the most out of Cassandra. Connect with us and become part of our growing community today.
© 2009-2023 The Apache Software Foundation under the terms of the Apache License 2.0. Apache, the Apache feather logo, Apache Cassandra, Cassandra, and the Cassandra logo, are either registered trademarks or trademarks of The Apache Software Foundation. Sponsored by Anant Corporation and Datastax, and Developed by Anant Corporation.

Get Involved with Planet Cassandra!

We believe that the power of the Planet Cassandra community lies in the contributions of its members. Do you have content, articles, videos, or use cases you want to share with the world?