'AWS VPN , Postman and Node process doesent resolve addresses
SCENARIO: Infrastructure: AWS Description: My needs is to be able to develop on my local linux machine an app in nodeJS that use remote openSearch database cluser not pubblically accessible under VPC and after that deploy the app on a production server in the same vpc. To be able to access the cluster from my local machine I've created a VPN endpoint and configured it, i configured the AWS VPN client on my local machine and now i'm able to access from my local machine the server dashboard web interface myDomain/_dashboards so the VPN seems to works fine.
PROBLEM: I created a request to get the index list of my server on postman, if i do the request from postman i get an EHOSTUNREACH error and i get the same error if i try to do an http request from my nodeJS process. If i export the PostmanRequest in curl format and i use my linux terminal to do the request the request goes well and i receive the response data.
It is like that postman , and node doesent be able to access the resorce on the VPN side or not be able to resolve its address, but my webBrowser and my linuxTermianl can, any suggestion of how to solve?
UPDATE: The Postman problems are unrealted to the nodes one, they are caused by the fact that postman try to connect to his api befoure contact the ones under vpn so if the "two" api sets are in different networks it cause the issue.
The node problem still persist, i've tryed different libraries and code snippets and the error is always the same. I post here only one code ( the moore clear and readable. )
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
node: 'https://mySearchDomain.com',
maxRetries: 5,
requestTimeout: 60000,
sniffOnStart: true,
auth: {
username: 'myUsername',
password: 'myPassword'
}}
);
console.log('before client initialization');
async function run () {
let result = await client.cat.count({});
console.log(result);
return result;
}
run()
.then((data)=>{
console.log("SUCCESS!");
console.log(data);
})
.catch((err)=>{
console.log("ERROR");
console.log(err);
})
return ;
Here the error:
before client initialization
ERROR
ConnectionError: connect EHOSTUNREACH 10.0.0.241:80
at ClientRequest.onError (/home/rino/PhpstormProjects/open_search_test2/node_modules/@elastic/elasticsearch/lib/Connection.js:123:16)
at ClientRequest.emit (events.js:311:20)
at Socket.socketErrorListener (_http_client.js:426:9)
at Socket.emit (events.js:311:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
name: 'ConnectionError',
meta: {
body: null,
statusCode: null,
headers: null,
meta: {
context: null,
request: [Object],
name: 'elasticsearch-js',
connection: [Object],
attempts: 5,
aborted: false
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
