我试图连接到AstraDB用于我的Python矢量搜索项目(用于我的GPT聊天机器人),但我收到了一个连接错误。(我遵循LangChain Cassandra Vector store示例中的示例,并希望使用AstraDB作为我的矢量数据库。
下面是我的代码:
ASTRA_DB_CLIENT_ID = os.getenv("ASTRA_DB_CLIENT_ID")
ASTRA_DB_APPLICATION_TOKEN = os.getenv("ASTRA_DB_APPLICATION_TOKEN")
ASTRA_DB_SECURE_BUNDLE_PATH = (
"/Users/devin.bost/proj/demos/ACI/secure-connect-vector-demo.zip"
)
cluster = Cluster(
cloud={
"secure_connect_bundle": ASTRA_DB_SECURE_BUNDLE_PATH,
},
auth_provider=PlainTextAuthProvider(
ASTRA_DB_CLIENT_ID,
ASTRA_DB_APPLICATION_TOKEN,
),
)
session = cluster.connect()
我已经将ASTRA_DB_CLIENT_ID设置为特定的CLIENT_ID,并对其他环境变量执行了相同的操作。
我得到这个错误:
Traceback (most recent call last):
File "cassandra/cluster.py", line 1703, in cassandra.cluster.Cluster.connect
File "cassandra/cluster.py", line 1690, in cassandra.cluster.Cluster.connect
File "cassandra/cluster.py", line 3488, in cassandra.cluster.ControlConnection.connect
File "cassandra/cluster.py", line 3533, in cassandra.cluster.ControlConnection._reconnect_internal
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'1d0ba879-1c8b-49e4-bc78-90baff9e5714-westus3.db.astra.datastax.com:29042:4cc2a061-0383-4355-85cd-699b4a5af93c': AuthenticationFailed('Failed to authenticate to 1d0ba879-1c8b-49e4-bc78-90baff9e5714-westus3.db.astra.datastax.com:29042:4cc2a061-0383-4355-85cd-699b4a5af93c: Error from server: code=0100 [Bad credentials] message="We recently improved your database security. To find out more and reconnect, see https://docs.datastax.com/en/astra/docs/manage-application-tokens.html"'), '1d0ba879-1c8b-49e4-bc78-90baff9e5714-westus3.db.astra.datastax.com:29042:a856cbcf-1faa-4098-84a0-94e221931fd8': AuthenticationFailed('Failed to authenticate to 1d0ba879-1c8b-49e4-bc78-90baff9e5714-westus3.db.astra.datastax.com:29042:a856cbcf-1faa-4098-84a0-94e221931fd8: Error from server: code=0100 [Bad credentials] message="We recently improved your database security. To find out more and reconnect, see https://docs.datastax.com/en/astra/docs/manage-application-tokens.html"'), '1d0ba879-1c8b-49e4-bc78-90baff9e5714-westus3.db.astra.datastax.com:29042:6f9150b3-c81a-4fcd-a61a-499ab11f09e8': AuthenticationFailed('Failed to authenticate to 1d0ba879-1c8b-49e4-bc78-90baff9e5714-westus3.db.astra.datastax.com:29042:6f9150b3-c81a-4fcd-a61a-499ab11f09e8: Error from server: code=0100 [Bad credentials] message="We recently improved your database security. To find out more and reconnect, see https://docs.datastax.com/en/astra/docs/manage-application-tokens.html"')})
python-BaseException
我已经仔细检查了凭证,确保它们没有作为空值传递给对象,验证了安全捆绑包对于DB是正确的,安全捆绑包路径是正确的,并确保令牌配置了足够的权限。会是什么问题呢?
1条答案
按热度按时间gopyfrb31#
问题是,当您将ASTRA_DB_CLIENT_ID从“token”更改为实际的CLIENT_ID时,实际上违反了示例。
如果你想使用token而不是客户端ID和secret,你需要将该参数设置为“token”,就像这样:
一般来说,每当凭据不正确时,都可能引发异常。
或者,在建立连接时,您可以使用客户端ID和客户端密码。下面是使用这种方法的更完整的示例(使用您的代码):
从官方的AstraDB门户网站上看到这个例子,相关部分用红色表示: