我是否需要使用 RDS IAM 身份验证每 15 分钟重新连接一次

Do I need to reconnect every 15 minutes with RDS IAM authentication

我正在使用带有 IAM 身份验证的 RDS postgresql。在我的应用程序中,它在连接到 RDS 集群之前在运行时生成令牌。基于 AWS 文档,

An authentication token is a string of characters that you use instead of a password. After you generate an authentication token, it's valid for 15 minutes before it expires. If you try to connect using an expired token, the connection request is denied.,

令牌仅在 15 分钟内有效。我的问题是我需要每 15 分钟重新连接一次吗?如果已经建立连接,是否需要为每个 query/insert/update 等提供令牌?如果它不需要令牌,则意味着我需要始终保持连接打开。 RDS 是否支持该连接模式?

My question is that do I need to reconnect every 15 minutes?

不,你不知道。令牌是建立连接所必需的,并不决定现有连接可以持续多长时间。如 here.

所述,在没有 activity 的情况下连接的默认值是 28800s(8 小时)

这意味着,如果您终止连接,或者 mysql 由于未被积极使用而终止连接,那么如果现有令牌已经过期,您需要为 re-connect 获取一个新令牌。