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 ·

Why is my connection test from the Getting Started with Astra UI unsuccessful?

I have populated all fields in the connection dialog of the Getting Started with Astra UI, as per instructions in the week 4 materials of the workshop, but when I test the connection I am getting an error about a refused connection. How can I overcome this error and succeed with the connection test?

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 ·

We have had a lot of users reporting problems establishing a successful database connection test after fully populating the connection dialog with the correct details in the connection dialog form of the getting-started-with-astra-ui.

All the supplied details are correct: User name, password, keyspace and connection bundle.

The connection issues happen when running in Gitpod.


Almost all these connection issues have to do with the fact that we need to cross post the credentials from the frontend service running on port 3000 to the backend service running on port 5000 (in the case of Python API) or port 8080 (in the case of Java API).

This is either very plainly visible in the failed post request on the UI, where we can see clearly that this is a CORS policy violation, or, less plainly, we see a connection refused error popping up immediately (i.e. there is no attempt made to contact the database), which again indicates that the connection is not refused at the database stage, it is refused between the frontend and the backend service.

In our efforts to overcome the CORS issues, we made some changes to enable CORS support on the backend APIs, but this does not seem to be sufficient. The best path to success is to unblock the CORS policy in the browser, too. For example, for Chrome, there are plugins available that handle this for you. We've been using a Chrome plugin named CORS Unblock.

Once this is installed, you can unblock and block CORS requests.

Now this affects what we want to set for the BASE_ADDRESS for both Python and Java backend. For both backends please use the public gitpod URL for the respective port in the .env file for the UI. Please no longer use the localhost address for Python, as this is now results in a refused connection due to the changes we made.

How to get the public gitpod UI? Once you have started your backend, check in the Open Ports tab in Gitpod. Make the port for your backend API public and open a browser. The URL in the browser is the public URL for this port.

For Python, add /api to assemble the correct base address.

e.g: BASE_ADDRESS=https://5000-d85fa17a-e121-4cf7-xxxx-9c4a7c277d2d.ws-eu01.gitpod.io/api

For Java, remove the swagger ending, and replace it with /api

e.g: BASE_ADDRESS=https://8080-d85fa17a-e121-4cf7-xxxx-9c4a7c277d2d.ws-eu01.gitpod.io/api

This setting, together with the unblocked CORS requests in your browser, should allow you to carry out the test.

If you still run into issue, please try with a local installation, where CORS is not an issue, since both services run truly on localhost in the local case.


Thanks all for your patience, it is a frustrating problem to not be able to carry out the connection test and progress through the exercise.

This is only a simple demo UI, and it clearly needed more testing! For a real application we would not normally design the UI in such a way that you would have to upload your database connection bundle, user names and passwords through a plainly visible POST request.


P.S. If you have problems populating the form data with the secure connection bundle on Windows 10, i.e. you can't upload it into the UI form, have a look here. https://community.datastax.com/questions/6841/secure-bundle-connect-error.html?childToView=6949#answer-6949

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.