0

我可以使用 ap-south-1 连接到 aws 密钥空间,但是当我将其更改为 us-east-2 时,它显示 “NoHostAvailable('无法连接到任何服务器', {'3.12.23.133:9142': OperationTimedOut( '错误=无,last_host =无')})“

我正在使用 python 进行连接

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)
4

1 回答 1

1

Amazon Keyspaces 要求为连接启用 SSL 以确保强大的安全性。如果您收到该错误,则可能缺少 SSL 参数。要解决此错误,您可以将--ssl标志添加到您的 cql 连接命令。我们听取了客户的意见,并创建了本指南以在您遇到连接问题时提供帮助。

于 2022-02-11T18:59:20.983 回答