Error elasticsearch on apigee

Dears ,

I have problem where i require elasticsearch library node.js app on apigee on-premise

Message Eroor

  1. ction_pool.js:59:0 at module.js:456:0 at module.js:474:0 at module.js:356:0 at module.js:312:0 at module.js:364:0 at require (module.js:380:0) at /organization/environment/api/node_modules/elasticsearch/src/lib/transport.js:105:0 at module.js:456:0 at module.js:474:0 at module.js:356:0 at module.js:312:0 at module.js:364:0 at require (module.js:380:0) at /organization/environment/api/node_modules/elasticsearch/src/lib/client.js:29:0 at module.js:456:0 at module.js:474:0 at module.js:356:0 at module.js:312:0 at module.js:364:0 at require (module.js:380:0) at /organization/environment/api/node_modules/elasticsearch/src/elasticsearch.js:10:0 at module.js:456:0 at module.js:474:0 at module.js:356:0 at module.js:312:0 at module.js:364:0 at require (module.js:380:0) at /organization/environment/api/Elastic.js:1:0 at module.js:456:0 at module.js:474:0 at module.js:356:0 at module.js:312:0

Elastic.js

var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
  host: 'localhost:9200',
  log: 'trace'
});


client.ping({
  // ping usually has a 3000ms timeout
  requestTimeout: 1000
}, function (error) {
  if (error) {
    console.trace('elasticsearch cluster is down!');
  } else {
    console.log('All is well');
  }
});

package.json

 {
  "name": "Elastic",
  "version": "1.2.3",
  "description": "ElasticSearch",
  "main": "elastic.js",
  "private": true,
  "dependencies":  {
    "elasticsearch": "x.x.x",
    "module-js": "7.0.1",
    "apigeetool": "0.10.0"
  }
}

As you install

  1. node_modules_elasticsearch.zip
  2. node_modules_apigeetool.zip
  3. node_modules_module-js.zip
0 3 214
3 REPLIES 3

sidd-harth
Participant V

As mentioned, you should be installing these modules and then re-deploy your proxy,

https://community.apigee.com/articles/1531/how-to-import-a-nodejs-module-to-apigee-edge.html

I hope you are aware of Apigee Nodejs - There are some drawbacks. The main one is the Trireme runtime is based on node 0.10.32. It's pretty old. And so it does not support ES6 including Promises, let/const, arrow function syntax, destructuring assignments, and so on. And that also means you cannot use the latest versions of various modules

sidd-harth
Participant V

Since you are using On-Prem...we cannot recommend Hosted Targets.

https://docs.apigee.com/api-platform/hosted-targets/hosted-targets-overview

Yes I know for that , So I develop node app

Can you see the bug @Anil Sagar @ Google