Connection refused errors not being retried #4027
Unanswered
heikkihiltunen
asked this question in
Q&A
Replies: 1 comment
-
Hi @heikkihiltunen, thanks for opening this discussion. By design, this type of errors are not retried by the SDK, however, you are welcome to implement your own retry strategy and decide which errors you would like to retry. Below there is a small example: import {S3Client, GetObjectCommand} from "@aws-sdk/client-s3";
import {StandardRetryStrategy} from "@aws-sdk/middleware-retry";
const MAX_ATTEMPTS = 3;
const customRetryStrategy = new StandardRetryStrategy(async () => MAX_ATTEMPTS, {
retryDecider: (err) => {
// Here we handle the type of errors we want to retry
if (err.$response.statusCode === STATUS_CODE_WANT_RETRY) {
return true;
}
return false;
}
});
const client = new S3Client({
region: 'us-east-2',
retryStrategy: customRetryStrategy
});
const response = await client.send(new GetObjectCommand({
Bucket: 'bucket',
Key: 'key'
}));
console.log(response); Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am testing sending SQS messages on node.js with @aws-sdk/client-sqs and a local ElasticMQ. When I simulate a connection error by turning off ElasticMQ, the operation does not get retried. The client does have a retry mechanism and for example timeout errors are being retried. By looking at the code in @aws-sdk/middleware-retry there does not seem to be any handling for connection refused (ECONNREFUSED) error. Shouldn't there be or is there some reason why they are not considered 'retryable' by the SDK?
Beta Was this translation helpful? Give feedback.
All reactions