0

I believe I'm doing exactly as mentioned in the documentation Python-driver-AstraDB

cloud_config= {
        'secure_connect_bundle': 'secure-connect-test-warehouse.zip'
}

logging.basicConfig(level=logging.DEBUG)

auth_provider = PlainTextAuthProvider(my_id, my_secret)
cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)
session = cluster.connect()

row = session.execute("select release_version from system.local").one()
if row:
    print(row[0])
else:
    print("An error occurred.")

I get the following error :

File "connect_database.py", line 23, in <module>
    session = cluster.connect()
  File "cassandra/cluster.py", line 1677, in cassandra.cluster.Cluster.connect
  File "cassandra/cluster.py", line 1713, in cassandra.cluster.Cluster.connect
  File "cassandra/cluster.py", line 1700, in cassandra.cluster.Cluster.connect
  File "cassandra/cluster.py", line 3507, in cassandra.cluster.ControlConnection.connect
  File "cassandra/cluster.py", line 3552, in cassandra.cluster.ControlConnection._reconnect_internal
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers
OSError(101, "Tried connecting to [('...', ..., 0, 0)]. Last error: Network is unreachable")})

I suspect Network is unreachable has to do with network latency I tried to set Cluster(cloud=cloud_config, auth_provider=auth_provider,control_connection_timeout=10) default of control_connection_timeout is 2.0, yet I get the same issue.

if correct how can I solve this ?

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
  • Can you get the secure bundle to work with another application or even cqlsh (standalone from Cassandra, not cqlsh in Astra)? Also, is the database hibernated? That actually may throw a different error, but definitely worth checking. – Aaron Aug 07 '23 at 13:43

1 Answers1

0

The documentation says to use the absolute path of the Secure Connect Bundle (SCB) as follows,

cloud_config= {
        'secure_connect_bundle': '/path/to/secure-connect-database_name.zip'
}

NOTE: Set the cloud_config parameter for the Cluster initialization as shown in the following example. The secure_connect_bundle must include the absolute path to your Astra DB database credentials (secure-connect-database_name.zip).

In which case, your code should look as below,

...
cloud_config= {
        'secure_connect_bundle': '/your_path/to/secure-connect-test-warehouse.zip'
}
...

Cheers!

Madhavan
  • 758
  • 4
  • 8
  • Thanks for your response, yet in spite of specifying the absolute path, I get the same error, here is the full it : `OSError(101, "Tried connecting to [('2c0f:fa18:0:10::224c:68c', 29042, 0, 0)]. Last error: Network is unreachable")` what are the possible issues causing this ? – Amine SAIHI Aug 06 '23 at 20:05
  • Sorry for that. Did you try to do a simple ping test to the IPs/hosts in question from the machine from your are trying to run this? – Madhavan Aug 10 '23 at 18:12