kritika arora
kritika arora

Reputation: 55

Unable to Connect to AWS Keyspace using a particular region

I am able to connect to aws keyspace using ap-south-1 but when I change it to us-east-2 it says "NoHostAvailable('Unable to connect to any servers', {'3.12.23.133:9142': OperationTimedOut('errors=None, last_host=None')})"

I am using python for connection

if __name__ == '__main__':
    sUsername = '******-at-43*****6380240297'
    sPassword = '********'
    sUrl = 'cassandra.us-east-2.amazonaws.com'
    sSSLCertPath = 'C:\\Users\\KArora\\Downloads\\sf-class2-root.crt'
    sPort = 9142
    session = getDBClient(sUrl, sUsername, sPassword, sPort, sSSLCertPath)

def getDBClient(sURL, sUserName, sPassword, sPort, sSSLCertPath):
    error = ""
    try:
        ssl_context = SSLContext(PROTOCOL_TLSv1_2)
        ssl_context.load_verify_locations(sSSLCertPath)
        ssl_context.verify_mode = CERT_REQUIRED
        auth_provider = PlainTextAuthProvider(username=sUserName, password=sPassword)
        sConn = []
        sConn.append(sURL)
        cluster = Cluster(sConn, ssl_context=ssl_context, auth_provider=auth_provider, port=sPort)
        session = cluster.connect()
        #error += "Success"
        return session
    except Exception as e:
        #error += "Failure"
        return str(e)

Upvotes: 0

Views: 464

Answers (1)

Autumn88
Autumn88

Reputation: 351

Amazon Keyspaces requires that SSL is enabled for connections to ensure strong security. The SSL parameter might be missing if you receive that error. To resolve this error you can add the --sslflag to your to your cql connection command. We've listened to our customers and we've created this guide to help if you run into connection issues.

Upvotes: 2

Related Questions