Build Cloud-Native apps with Apache Cassandra

GOT QUESTIONS from the Workshop? You're in the right place! Post a question here and we'll get you answers.

Click here for Week 8 Materials and Homework.

Follow us on Eventbrite to get notified when new workshops are scheduled!


question

bettina.swynnerton avatar image
bettina.swynnerton asked ·

How to upload the secure connection bundle via UI when using Java backend in Gitpod?

If you are having trouble uploading the Astra secure connection bundle through the Getting Started with Astra UI, using the Java backend API, please verify you followed the steps outlined in the answer below.

If you still face issues, comment with a screenshot from POST error in the browser developer tools.

If you are using the Python backend API, check this other post.

workshop-faq
10 |1000 characters needed characters left characters exceeded

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

1 Answer

bettina.swynnerton avatar image
bettina.swynnerton answered ·

Hi,

thanks for attending week 4 of the Cassandra Cloud-Native Workshop Series.

If you followed along and have problems uploading the secure connection bundle through the UI while running on Gitpod and using the Java API, check that you followed the following steps.

There will be a separate post for Python, and if you are running locally, it is unlikely that you run into this issue.

Step 1:

Start Gitpod and then start the java backend:

Navigate to the getting-starrted-with-astra-java directory and run mvn spring-boot: run


Step 2:

Make port 8080 public, and open a browser

The browser will open up with swagger:

Step 3:

In your brower, copy the URL. You will need it to configure the UI.

It will look similar to this (this is uniquely generated for your gitpod workspace)

https://8080-aee20c95-8521-45ca-b622-e4270a6ad672.ws-eu01.gitpod.io/swagger-ui.html

this will form our BASE_ADDRESS url that we need to give to the UI


Step 4:

Create a .env file for UI, in the root directory of getting-started-with-astra-ui


It needs to contain this text. This is the URL that you copied from your browser (replace the swagger-ui.html with the /api route)

BASE_ADDRESS = https://8080-aee20c95-8521-45ca-b622-e4270a6ad672.ws-eu01.gitpod.io/api

Obviously, you use your own URL here

Important: Do not use a localhost address here. You need to use the gitpod URL.


Step 5:

Open new terminal and navigate to the getting-started-with-astra-ui folder

run npm install

then start the UI with npm run start

Make port 3000 public and start a browser.


Step 6:

In your browser, populate the credentials and click Test

If the test is successful, you will see a green confirmation in the lower left hand corner of the browser screen.

That's it! You are good, you can now proceed to saving this connection and launch your spaceships.


Step 7, in case you run into connection issues like this:

Open your browser's development tool, and take a note of the POST and GET errors when testing the connection (you can ignore other errors about sock.js, sorry about those)

For example, these are the POST and GET errors when the base address is configured for localhost

If you are seeing other POST or GET errors here, please attach them to the comments, we will help to to troubleshoot.


21 comments Share
10 |1000 characters needed characters left characters exceeded

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

Hi @bettina.swynnerton,

I have followed the above steps for launching spacecraft, but i encountered error during the launch. My Database name, password and keyspace name are correct as per Astra instance. A screenshot has been attached for your reference.

0 Likes 0 · ·
spacecraft2.jpg (272.7 KiB)

Hi @chandrasekar.b03_190734,

in your case this is definitely blocked by the CORS policy, you can see that in your error messages. We will make an update to the Java code to get past this.

Or you can temporarily disable this security feature, Chrome has plugins for that, but you might not want to do this.

In the meantime, you can try to use the Python backend, where we can use the localhost address, this should get you past the CORS issues.

Detailed steps are here:

https://community.datastax.com/questions/6796/how-to-upload-the-secure-connection-bundle-via-ui-1.html

1 Like 1 · ·
bettina.swynnerton avatar image bettina.swynnerton ♦♦ bettina.swynnerton ♦♦ ·

We just updated the code and have added a CORS filter just now in the code you can try "git pull" and restart the java backend with "mvn clean spring-boot:run"

0 Likes 0 · ·
Show more comments

For me, both "Test" and "Save" don't work. Here's how it looks in dev tools:

0 Likes 0 · ·

I think that this is also due to CORS. We will make an update to the Java backend to get past this.

In the meantime, could you try the Python backend, to see if this allows you the successful connection?

All steps here:

https://community.datastax.com/questions/6796/how-to-upload-the-secure-connection-bundle-via-ui-1.html

If you prefer to stay with Java, try it locally, where we have no cross site scripting issues, as both backend and frontend will run on localhost.

0 Likes 0 · ·
bettina.swynnerton avatar image bettina.swynnerton ♦♦ bettina.swynnerton ♦♦ ·

We just updated the code and have added a CORS filter just now in the code you can try "git pull" and restart the java backend with "mvn clean spring-boot:run"

0 Likes 0 · ·
Show more comments

What a great response, KUDO

2 Likes 2 · ·

Hi @Cedrick Lunven,

[Follow-up comment posted as question #6902]

0 Likes 0 · ·

Hi @chandrasekar.b03_190734,

I've posted this as a new question on your behalf, makes it easier to follow than this long comment trail.

Cheers!

1 Like 1 · ·
Show more comments