question

sangr avatar image
sangr asked Erick Ramirez edited

Test connection to Astra hangs in week 3 of Workshop Series

Cassandra workshop series week3 - Unable to connect to DB in Astra using the connection bundle from gidpod

Running the java unit test from GitPod just hangs at the point its trying to connect to the DB. Any idea what i might be missing?

NOTE: secure connection bundle for my DB, killrvideo on Astra is downloaded and path provided in the DatabaseConnection class already.

Thanks in advance !

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Picked up JAVA_TOOL_OPTIONS: -Xmx1879m
Running com.datastax.workshop.Ex02_Connect_to_Cassandra
19:34:40.371 INFO Exercise2 : ========================================
19:34:40.373 INFO Exercise2 : Start exercise
19:34:40.375 INFO Exercise2 : File /workspace/cassandra-workshop-series/week3-AppDev-crud/secure-connect-killrvideocluster.zip located

[UPDATE] I am using Java 11. I am using classic database in Astra and not serverless. I tried the below as you suggested, however it continues to hang at the same place. Possible to run these tests in Java 11?

mvn test -Djdk.tls.client.protocols="TLSv1.2" -Dtest=com.datastax.workshop.Ex02_Connect_to_Cassandra
mvn test -Djdk.tls.client.protocols=TLSv1.2 -Dtest=com.datastax.workshop.Ex02_Connect_to_Cassandra
gitpod /workspace/cassandra-workshop-series/week3-AppDev-crud/crud-java $ mvn test -Djdk.tls.client.protocols=TLSv1.2 -Dtest=com.datastax.workshop.Ex02_Connect_to_Cassandra
Picked up JAVA_TOOL_OPTIONS: -Xmx1879m
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.datastax.workshop:crud-java:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 76, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 72, column 12
workshopastra
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered

It's not readily obvious to me what the problem is from the description you provided.

I'm assuming that you are working on step 3 of this exercise -- https://github.com/DataStax-Academy/cassandra-workshop-series/blob/master/week3-AppDev-crud/README_JAVA.MD.

If you are, all that it is doing is connecting to Astra and getting the keyspace from the session object:

        try (CqlSession cqlSession = CqlSession.builder()
                .withCloudSecureConnectBundle(Paths.get(DBConnection.SECURE_CONNECT_BUNDLE))
                .withAuthCredentials(DBConnection.USERNAME, DBConnection.PASSWORD)
                .withKeyspace(DBConnection.KEYSPACE)
                .build()) {
            
            // Then
            LOGGER.info("Connected with Keyspace {}", cqlSession.getKeyspace().get());

My suggestion is to check that the keyspace you created on Astra matches what you configured in DBConnection:

String SECURE_CONNECT_BUNDLE = "/workspace/cassandra-workshop-series/week3-AppDev-crud/secure-connect-killrvideoclusters.zip";
String USERNAME = "KVUser";
String PASSWORD = "KVPassword";
String KEYSPACE = "killrvideo";

Make sure that you've recompiled the app on Gitpod before running the test.

Alternatively, make sure your Astra DB is operational by checking the status on the dashboard. Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Cedrick Lunven avatar image
Cedrick Lunven answered Cedrick Lunven edited

Thank you @sangr for your questions.

I would see multiple root causes here:

  • (pretty sure) your are using JDK11+ with TLS 1.3 enabled by default. The cloudSecureBundkle work only for TLS1.2 try to add in the command :
‑Djdk.tls.client.protocols="TLSv1.2"
  • Make sure you did not pick a serverless instance for your Astra Database, it will not work. The username would have to be "token" we are ugrading this tomorrow.

Best regards

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.