I made a code using aws sdk as below.
var winston = require('winston'),
WinstonCloudWatch = require('winston-cloudwatch');
const express = require('express')
const app = express()
const AWS = require('aws-sdk');
AWS.config.update({
maxRetries: 2, region: 'us-northeast-2', accessKeyId: "", secretAccessKey: ""
});
winston.add(new WinstonCloudWatch({
cloudWatchLogs: new AWS.CloudWatchLogs(),
logGroupName: 'testing',
logStreamName: 'first'
}));
app.listen(3000, () => {
winston.error('1');
console.log('bound')
})
This is really simple code.
But the thing is I want to retry this only two times when it fails in various situations.
In this case, it can't accessed without accessKey and secretAccessKey.
Therefore, it is obvious, it can't be accessed.
It gives this error in the console.
UnknownEndpoint: Inaccessible host:
logs.us-northeast-2.amazonaws.com' at portundefined'. This service may not be available in the `us-northeast-2' region. at Request.ENOTFOUND_ERROR (C:\Users\dd\Desktop\abc\node_modules\aws-sdk\lib\event_listeners.js:529:46) at Request.callListeners (C:\Users\dd\Desktop\abc\node_modules\aws-sdk\lib\sequential_executor.js:106:20) at Request.emit (C:\Users\dd\Desktop\abc\node_modules\aws-sdk\lib\sequential_executor.js:78:10) at Request.emit (C:\Users\dd\Desktop\abc\node_modules\aws-sdk\lib\request.js:686:14) at error (C:\Users\dd\Desktop\abc\node_modules\aws-sdk\lib\event_listeners.js:361:22) at ClientRequest. (C:\Users\dd\Desktop\abc\node_modules\aws-sdk\lib\http\node.js:99:9) at ClientRequest.emit (events.js:315:20) at ClientRequest.EventEmitter.emit (domain.js:486:12) at TLSSocket.socketErrorListener (_http_client.js:469:9) at TLSSocket.emit (events.js:315:20) { code: 'UnknownEndpoint', region: 'us-northeast-2', hostname: 'logs.us-northeast-2.amazonaws.com', retryable: true,
originalError: Error: getaddrinfo EAI_AGAIN logs.us-northeast-2.amazonaws.com at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) { errno: -3001, code: 'NetworkingError', syscall: 'getaddrinfo', hostname: 'logs.us-northeast-2.amazonaws.com', region: 'us-northeast-2', retryable: true, time: 2021-11-27T13:50:14.938Z }, time: 2021-11-27T13:50:14.938Z }
But I set an option as maxRetries:2 in aws config.
Nevertheless, it retries infinitely.
Could I retry only two times in this case?
Thank you for reading my question.