http-aws-es icon indicating copy to clipboard operation
http-aws-es copied to clipboard

UnhandledPromiseRejectionWarning: The security token included in the request is invalid.

Open ghost opened this issue 7 years ago • 1 comments

Unhandled promise rejection (rejection id: 1): UnrecognizedClientException: The security token included in the request is invalid.

Hi, I try to catch this Exception, but I can't do that.

What should I do in that case, I call the ping method from ES, after that I will return the health for that.

router.route('/health').get(function (req, res, next) {
    let client = ES.Client({
        hosts: [config.elasticSeachUrl],
        connectionClass: require('http-aws-es'),
        awsConfig: new AWS.Config({
            region: config.awsZone
        })
    }).catch((error) => {
        console.log(error)
    });
    client.ping({
            // ping usually has a 3000ms timeout
            requestTimeout: 1000
        })
        .then(() => console.log('finish'))
        .catch((err) => console.log(err));

});

but it always is throwing me the exception but i can't to catch that.

ghost avatar Feb 06 '18 17:02 ghost

I've also seen this when scrolling:

Error: Authorization Exception
at respond (/home/node/app/node_modules/elasticsearch/src/lib/transport.js:308:15)
at checkRespForFailure (/home/node/app/node_modules/elasticsearch/src/lib/transport.js:267:7)
at done (/home/node/app/node_modules/http-aws-es/connector.js:48:7)
at IncomingMessage.cleanUp (/home/node/app/node_modules/http-aws-es/src/node.js:20:7

{
status: 403,
displayName: 'AuthorizationException',
message: 'Authorization Exception',
path: '/_search/scroll',
query: { scroll: '30s' },
body:  { message: 'The security token included in the request is invalid' },
}

austince avatar Sep 03 '19 13:09 austince