3

Im trying to connect to my aws keyspaces using spring-boot-starter-data-cassandra-reactive and I get the following error:

Error creating bean with name 'cassandraSession' defined in class path resource [com/pams/framework/windsoncore/configurations/CassandraConfiguration.class]: Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=cassandra.us-east-2.amazonaws.com:9142, hostId=null, hashCode=33a6c4f3): [com.datastax.oss.driver.api.core.DriverTimeoutException: [s5|control|id: 0xe0ebe047, L:/10.0.0.128:54474 - R:cassandra.us-east-2.amazonaws.com/3.12.23.155:9142] Protocol initialization request, step 1 (OPTIONS): timed out after 500 ms]

I tried their documentation, that works, but I wanted to used the spring auto configuration and reactive cassandra repos. I added all the configurations in application.yml and passed the trustStore information as JVM args. But I cannot get past these errors. I've tried looking around for this and have not found a working solution.

I would appreciate if someone can help me out here.

I have also tried the following:

@Configuration
@Slf4j
@EnableReactiveCassandraRepositories
public class CassandraConfiguration extends AbstractReactiveCassandraConfiguration {

  
  @Override
  protected String getContactPoints() {
    return "cassandra.us-east-2.amazonaws.com";
  }

  @Override
  protected int getPort() {
    return 9142;
  }

  @Override
  protected String getKeyspaceName() {
    return "windson";
  }

  @Override
  protected CqlSession getRequiredSession() {
    // TODO Auto-generated method stub
    DriverConfigLoader loader = DriverConfigLoader.fromClasspath("application.conf");

    return CqlSession.builder().withConfigLoader(loader).build();
  }
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Pavan Kumar
  • 157
  • 2
  • 4
  • 17

1 Answers1

1

You need to increase connection timeout in the application.conf file to:

datastax-java-driver {
  advanced.connection {
    connect-timeout = 5 seconds
    init-query-timeout = 5 seconds
  }
}

or upgrade to Java driver 4.9 where the init-query-timeout is already increased from 500 milliseconds to 5 seconds.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
  • Thanks @Alex Ott. But what if I wanted to use the auto configuration from spring? Where do i plug this value in my yaml? Or else, which method should i override in abstract cassandra configuration file? – Pavan Kumar Sep 06 '20 at 10:04
  • I also see a bunch of logs which say the following. ` Error while opening new channel (ConnectionInitException: [s4|id: 0x1549b4a1, L:/10.0.0.128:58600 - R:3.12.23.181/3.12.23.181:9142] Protocol initialization request, step 1 (STARTUP {CQL_VERSION=3.0.0, DRIVER_NAME=DataStax Java driver for Apache Cassandra(R), DRIVER_VERSION=4.6.1, CLIENT_ID=5312df78-ecaa-4715-a3c4-90abf77650eb}): failed to send request (javax.net.ssl.SSLException: SSLEngine closed already)) ` BTW, Im using spring-data-cassandra-reactive library and not datastax explicitly. So any information around this would also help! – Pavan Kumar Sep 06 '20 at 10:10
  • I'm not Spring person, so couldn't answer about configuration file. But application.conf should be picked up automatically. The driver options could be specified in the Spring config file as well, but I'm not sure about syntax. It could be something like this (https://www.datastax.com/blog/2019/09/datastax-spring-boot-starter-java-driver), but I'm not sure. For 2nd error - you need to configure SSL for driver - in driver itself it's done as described here: https://docs.datastax.com/en/developer/java-driver/4.9/manual/core/ssl/ – Alex Ott Sep 06 '20 at 12:09