TheDeveloper / http-aws-es

Use the elasticsearch-js client with Amazon ES
https://www.npmjs.com/package/http-aws-es
MIT License
262 stars 129 forks source link

[Solved] Getting "No Living connections" error after using http-aws-es #57

Closed sriharshakappala closed 5 years ago

sriharshakappala commented 5 years ago

@TheDeveloper I too was facing the issue User: anonymous is not authorized to perform: es:ESHttpPost and found your package via Stackoverflow. Based on the findings I changed my es-client code in the below way.

const AWS = require('aws-sdk');
const config = require('../../configuration');
const elasticsearch = require('elasticsearch');

const esClient = new elasticsearch.Client({
  host: config.get('elasticsearch.rental.host'),
  log: config.get('elasticsearch.log_level'),
  connectionClass: require('http-aws-es'),
  amazonES: {
    region: 'us-west-2',
    credentials: new AWS.EnvironmentCredentials('AWS'),
  },
});

module.exports = esClient;

But now I am getting No Living connections. 7 hours now and still not able to figure out what's happening. Any ideas what might be going wrong?

ankurlathwal commented 5 years ago

I am getting the exact same error. And my code is also the exactly same. Can somebody help with this?

ankurlathwal commented 5 years ago

Ok. I figured this out. There's some problem with specifying the region. @sriharshakappala - Add this line -

const AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
sriharshakappala commented 5 years ago

I have fixed by doing in the below way. I have to use AWS.ECSCredentials since my app is running inside ECS cluster.

const AWS = require('aws-sdk');
const config = require('../../configuration');
const elasticsearch = require('elasticsearch');

const credentials = new AWS.ECSCredentials({
  httpOptions: {timeout: 5000},
  maxRetries: 10,
});

const esClient = new elasticsearch.Client({
  host: config.get('elasticsearch.rental.host'),
  log: config.get('elasticsearch.log_level'),
  connectionClass: require('http-aws-es'),
  awsConfig: new AWS.Config({
    region: 'us-west-2',
    credentials: credentials,
  }),
});

module.exports = esClient;
dorman99 commented 3 years ago

still not working on me