lifion / lifion-kinesis

A native Node.js producer and consumer library for Amazon Kinesis Data Streams
MIT License
86 stars 18 forks source link

Can't consume message #424

Open ziv-kalderon opened 3 years ago

ziv-kalderon commented 3 years ago

Hey guys, First of all, this package is exactly what we were looking for... Second, currently the message consuming is not working for me with localstack Do you have any experience with it?

My localstack docker-compose.yml

version: '2.1'

services:
  localstack-container:
    container_name: "localstack-container"
    privileged: true
    image: localstack/localstack:0.11.0
    ports:
      - "4566-4599:4566-4599"
      - "8081:8081"
    # https://github.com/localstack/localstack#configurations
    environment:
      - SERVICES=kinesis,dynamodb
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
      - KINESIS_STREAM_SHARDS=1
      - KINESIS_ERROR_PROBABILITY=0.0
      - KINESIS_STREAM_NAME=my-stream
      - DEFAULT_REGION=us-east-1
    volumes:
      - "./localstack/tmp/localstack:/tmp/localstack"
      - "./localstack/tmp/localstack/run/docker.sock:/var/run/docker.sock"

My code:

 this.consumer = new KinesisClient({
      streamName: 'my-stream',
      accessKeyId: 'test',
      secretAccessKey: 'test',
      endpoint: 'http://127.0.0.1:4568',
     region: 'us-east-1',
      dynamoDb: {
        region: 'us-east-1',
      },
    });

 this.consumer.on('data', (data: any) => {
      console.log('Incoming data:', data);
    });
await this.consumer.startConsumer();

But nothing happens(and not errors)... Any idea why?

ziv-kalderon commented 3 years ago

So apparently you need accessKeyId And secret AccessKey for the dynamoDb as well

 dynamoDb: {
        region: 'us-east-1',
        endpoint: 'http://localhost:4566',
        accessKeyId: 'test',
        secretAccessKey: 'test',
      },