简体   繁体   中英

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)

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 --ssl flag 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM