Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccessible host localhost error when calling the createStream method and using NodeJS 16 #121

Open
nou2003 opened this issue Nov 9, 2023 · 0 comments

Comments

@nou2003
Copy link

nou2003 commented Nov 9, 2023

I'm getting the below error when calling the createStream method and using NodeJS 16. The same code is working on NodeJS 14.
The code below is used in a unit test with mocha

### This is the error

Kinesalite started on port 14567
UnknownEndpoint: Inaccessible host: localhost'. This service may not be available in the us-east-1' region.
at Request.ENOTFOUND_ERROR

### This is the code throw error

const localKinesis = require('local_kinesis');

const setupKinesis = async () => {
kinesis = kinesis || await localKinesis.start();
try {
stream = stream || await kinesis.createStream({
ShardCount: 1,
StreamName: streamName
}).promise();
}
catch (e) {
console.log(e.stack);
console.log(e.name);
console.log(e.message);
console.log('Stream already exists, skipping');
}
};

### local_kinesis is defined as

const AWS = require('aws-sdk');
const kinesalite = require('kinesalite');
const kinesisLocalPort = 14567;

const startKinesis = async (kinesaliteServer) => {
kinesaliteServer.listen(kinesisLocalPort, (err) => {
if (err) throw err;
console.log(Kinesalite started on port ${kinesisLocalPort});
});
};

const start = async () => {
// Returns a standard Node.js HTTP server
const kinesaliteServer = kinesalite({
path: './kinesisTemp',
createStreamMs: 0
});

const kinesis = new AWS.Kinesis({
endpoint: http://localhost:${kinesisLocalPort},
region: 'us-east-1'
});
await startKinesis(kinesaliteServer);
kinesis._server = kinesaliteServer;
return kinesis;
};

const stop = async (kinesis) => {
kinesis._server.close();
};

module.exports = {
start,
stop
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant