I was deploying Datastax exactly as the Datastax website says and even used virtualenv but then I got an error:
cassandra.cluster.NoHostAvailable
I'm using windows 10.
I heard something about when one of my nodes go offline this error might occur but I have no idea what this means or how to fix it.
When I try to deploy Datastax exactly as the website says with bundle and token and all that I get this error:
raise NoHostAvailable("Unable to connect to any servers", errors)
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'20ad12f9-ae53-4b0a-a66a-01fd426bbdd3-us-east1.db.astra.datastax.com:29042:3fc0355c-8dc0-4fde-b81f-b55692bc4856': RuntimeError("ssl_options specify 'check_hostname', but ssl.match_hostname is not provided. Patch or upgrade Python to use this option."), '20ad12f9-ae53-4b0a-a66a-01fd426bbdd3-us-east1.db.astra.datastax.com:29042:45c38e37-2440-46d5-9312-d7846a7df2a0': RuntimeError("ssl_options specify 'check_hostname', but ssl.match_hostname is not provided. Patch or upgrade Python to use this option."), '20ad12f9-ae53-4b0a-a66a-01fd426bbdd3-us-east1.db.astra.datastax.com:29042:ed8a594e-e434-435b-ba06-f8831de2d1fb': RuntimeError("ssl_options specify 'check_hostname', but ssl.match_hostname is not provided. Patch or upgrade Python to use this option.")})
@Aaron I followed each step as you said and still got the same error i set ASTRADB_TOKEN and SECURE BUNDLE my code is:
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
import os
username = "token"
token = os.environ['ASTRA_DB_TOKEN']
secureBundleLocation =
os.environ['ASTRA_DB_SECURE_BUNDLE_LOCATION']
cloud_config= {
'secure_connect_bundle': secureBundleLocation,
'use_default_tempdir': False,
}
auth_provider = PlainTextAuthProvider(username, token)
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.")
the error: cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers. RuntimeError("ssl_options specify 'check_hostname', but ssl.match_hostname is not provided. Patch or upgrade Python to use this option.").
i cant put the whole error for some reason but this parts seems important
thanks for helping, very appriciated.
Thanks for the question!
I'm guessing you're trying out this code using Python 3.12. That version of Python removed a function that our SSL implementation relied upon. Fortunately we've just released a new version of the Python driver which should fully support Python 3.12, including a new implementation to replace the removed function.
If you want the grisly details you can find them on PYTHON-1331, specifically this comment which discusses the function that's been removed.