chandrasekar.b03_190734 avatar image
chandrasekar.b03_190734 asked commented

How to overcome connection timeouts when connecting from local machine to Astra?

Gitpod is always good for coding fantasy. but when it comes to an IDE, configuration and connection to Astra instance is a horrible scenario. I myself spent a week and 2 days since week3 option1 for connecting via IDE (IntelliJ in my case) , python 3.6.5 and still not able to connect.

Latency plays a vital role here , This is a fact.

i'm from india (chosen Europe-west1 DC) and i cannot execute both week3 code and week4 code locally on my system. I dont know how i can solve this issue :((

java driverastra
10 |1000

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 commented

Hi @chandrasekar.b03_190734,

from our discussion I understood that you are following this example with Java driver 4.6 or newer:

and you are getting timeout errors during the initial connection (I have removed all cluster ids and ip addresses from this error message):

Exception in thread "main" 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(, hostId=null, hashCode=4f515049): [com.datastax.oss.driver.api.core.DriverTimeoutException: [s0|control|id: 0x6c6b084d, L:/ -] Protocol initialization request, step 1 (OPTIONS): timed out after 500 ms]

As you can see, the connection times out after 500ms, and we have seen a few instances where this is too aggressive, also for connections from Europe to Astra Europe West1.

The recommendation is to increase the timeouts.

You can do this by setting advanced options in. the application.conf, which is the recommended way to configure the driver.

To read up about the application.conf, please see this documentation:

To get you going for a simple test, make the following changes to your project.

Add an application.conf file in the classpath (or an absolute path, or an URL). It only needs to contain the options that you override. For example, in my IntelliJ project, I create the file application.conf in the resources folder of the project.

Set the following options in the application.conf:

datastax-java-driver {

  advanced.connection {
    connect-timeout = 10 second
    init-query-timeout = 10 seconds
    set-keyspace-timeout = 10 seconds


  advanced.control-connection {
    timeout = 10 seconds

The driver ships with a reference.conf (you can find it in the driver package for inspection), where you can read more about these settings.

Let us know if this enables you to establish a successful connection.

3 comments 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. avatar image commented ·

Does this look like a latency problem too? it is the simple standalone connection from cqlsh-astra to the Astra.

cassandra.DriverException: Unable to connect to the metadata service at Check the cluster status in the Constellation cloud console.

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

oh, you are getting this on the cql shell on Astra itself?

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

Adding an application.conf file to the CLASSPATH didn't work.

I will try the REST interface

0 Likes 0 ·