Bedrock Runtime: InvokeModel, exceeded maximum number of attempts, 3, https resp...
错误信息
InvokeModel: operation error Bedrock Runtime: InvokeModel, exceeded maximum number of attempts, 3, https response error StatusCode: 503, RequestID: 8cc2c021-24c9-479e-a0bc-2a2884ddc780, ServiceUnavailableException: Bedrock is unable to process your request. (aws_invoke_error)
AI 解决方案
🔍 报错分析
1. 🌐 错误翻译
原文:InvokeModel: operation error Bedrock Runtime: InvokeModel, exceeded maximum number of attempts, 3, https response error StatusCode: 503, RequestID: 8cc2c021-24c9-479e-a0bc-2a2884ddc780, ServiceUnavailableException: Bedrock is unable to process your request. (aws_invoke_error)
译文:InvokeModel:操作错误 Bedrock Runtime:InvokeModel,超过最大尝试次数3次,https响应错误 状态码:503,请求ID:8cc2c021-24c9-479e-a0bc-2a2884ddc780,服务不可用异常:Bedrock无法处理您的请求。
2. 🎯 原因分析
InvokeModel操作时,与AWS Bedrock服务端的HTTP连接过程中。3. 💡 解决方案
该错误由AWS Bedrock服务端问题导致,无法通过修改代码直接修复,需采取以下步骤:
示例:为AWS SDK调用添加重试配置(以JavaScript为例):
const { BedrockRuntimeClient, retryMiddleware } = require('@aws-sdk/client-bedrock-runtime');
const client = new BedrockRuntimeClient({
region: 'your-region',
retryStrategy: () => ({
maxAttempts: 10, // 将最大重试次数提升至10次
retryDecider: (error) => {
// 仅针对503服务不可用错误进行重试
if (error.$metadata?.httpStatusCode === 503) {
return true;
}
return false;
},
backoffDecider: (retryCount) => Math.pow(2, retryCount) * 1000, // 指数退避,每次重试间隔加倍
}),
});
// 正常发起InvokeModel请求
const response = await client.send({
modelId: 'your-model-id',
body: JSON.stringify({ input: 'your-input' })
});
4. 🛡️ 预防措施
retryStrategy配置),其内置了针对服务端错误的智能重试逻辑,无需手动实现。