[英]Debugging ENOTFOUND error using aws sdk v3
I've been using AWS JS SDK V3 and have noticed that my lambdas are intermittently hitting errors connecting to AWS resources.我一直在使用 AWS JS SDK V3,并注意到我的 lambda 表达式间歇性地遇到连接到 AWS 资源的错误。 Below I have an example for dynamodb, but I have also had issues connecting to secrets manager.下面我有一个 dynamodb 的例子,但我在连接到 secrets manager 时也遇到了问题。 My lambdas and resources are all contained within a VPC.我的 lambda 和资源都包含在一个 VPC 中。 I've noticed that these issues seem to be hit more often during a lambda cold start, but I'm not entirely sure.我注意到这些问题似乎在 lambda 冷启动期间更频繁地出现,但我不完全确定。 If a request is resent (user on the frontend refreshes the page) this error seems to go away.如果重新发送请求(前端用户刷新页面),此错误似乎消失了 go。 I was hoping that the built in client retries would reduce the errors that my code sees, but it appears that no retries are attempted.我希望内置的客户端重试会减少我的代码看到的错误,但似乎没有尝试重试。
I am looking for potential debugging tips that might reveal what is the cause of these issues.我正在寻找可能揭示这些问题的原因的潜在调试技巧。 So far I've been looking through cloudwatch logs which does not appear to have any good insights.到目前为止,我一直在查看似乎没有任何好的见解的 cloudwatch 日志。 I believe this is being cause by bad DNS resolution, but I am surprised by the frequency of these errors.我相信这是由错误的 DNS 分辨率引起的,但我对这些错误的频率感到惊讶。 Stopping short of moving my lambdas to ec2 and utilizing a cache, what are ways in which I can fix this.除了将我的 lambda 表达式移至 ec2 并利用缓存之外,还有哪些方法可以解决此问题。
Reading this article: https://aws.amazon.com/premiumsupport/knowledge-center/vpc-find-cause-of-failed-dns-queries/ suggests increasing the DNS retry timer, but I'm unsure how I would do that as well.阅读这篇文章: https://aws.amazon.com/premiumsupport/knowledge-center/vpc-find-cause-of-failed-dns-queries/建议增加 DNS 重试计时器,但我不确定我会怎么做那也是。
{
"errorType": "Error",
"errorMessage": "getaddrinfo ENOTFOUND dynamodb.us-east-1.amazonaws.com",
"code": "ENOTFOUND",
"errno": -3008,
"syscall": "getaddrinfo",
"hostname": "dynamodb.us-east-1.amazonaws.com",
"$metadata": {
"attempts": 1,
"totalRetryDelay": 0
},
"stack": [
"Error: getaddrinfo ENOTFOUND dynamodb.us-east-1.amazonaws.com",
" at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)"
]
}
How do you connect to DynamoDB from within your VPC?您如何从您的 VPC 连接到 DynamoDB?
Are you using a NAT instance or gatway?您使用的是 NAT 实例还是网关?
Are you using custom DNS resolution?您使用的是自定义 DNS 分辨率吗?
I would suggest that you add a DynamoDB VPCe to your VPC to allow you to connect to DynamoDB via AWS private.network.我建议您将 DynamoDB VPCe 添加到您的 VPC 以允许您通过 AWS private.network 连接到 DynamoDB。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.