GithubHelp home page GithubHelp logo

awslabs / amazon-kinesis-client-nodejs Goto Github PK

View Code? Open in Web Editor NEW
294.0 30.0 203.0 297 KB

Amazon Kinesis Client Library for Node.js

License: Apache License 2.0

JavaScript 99.65% Batchfile 0.35%

amazon-kinesis-client-nodejs's Introduction

Amazon Kinesis Client Library for Node.js

This package provides an interface to the Amazon Kinesis Client Library (KCL) MultiLangDaemon for the Node.js framework.

Developers can use the KCL to build distributed applications that process streaming data reliably at scale. The KCL takes care of many of the complex tasks associated with distributed computing, such as load-balancing across multiple instances, responding to instance failures, checkpointing processed records, and reacting to changes in stream volume.

This package wraps and manages the interaction with the MultiLangDaemon, which is provided as part of the Amazon KCL for Java so that developers can focus on implementing their record processing logic.

A record processor in Node.js typically looks like the following:

var kcl = require('aws-kcl');
var util = require('util');

/**
 * The record processor must provide three functions:
 *
 * * `initialize` - called once
 * * `processRecords` - called zero or more times
 * * `shutdown` - called if this KCL instance loses the lease to this shard
 *
 * Notes:
 * * All of the above functions take additional callback arguments. When one is
 * done initializing, processing records, or shutting down, callback must be
 * called (i.e., `completeCallback()`) in order to let the KCL know that the
 * associated operation is complete. Without the invocation of the callback
 * function, the KCL will not proceed further.
 * * The application will terminate if any error is thrown from any of the
 * record processor functions. Hence, if you would like to continue processing
 * on exception scenarios, exceptions should be handled appropriately in
 * record processor functions and should not be passed to the KCL library. The
 * callback must also be invoked in this case to let the KCL know that it can
 * proceed further.
 */
var recordProcessor = {
  /**
   * Called once by the KCL before any calls to processRecords. Any initialization
   * logic for record processing can go here.
   *
   * @param {object} initializeInput - Initialization related information.
   *             Looks like - {"shardId":"<shard_id>"}
   * @param {callback} completeCallback - The callback that must be invoked
   *        once the initialization operation is complete.
   */
  initialize: function(initializeInput, completeCallback) {
    // Initialization logic ...

    completeCallback();
  },

  /**
   * Called by KCL with a list of records to be processed and checkpointed.
   * A record looks like:
   *     {"data":"<base64 encoded string>","partitionKey":"someKey","sequenceNumber":"1234567890"}
   *
   * The checkpointer can optionally be used to checkpoint a particular sequence
   * number (from a record). If checkpointing, the checkpoint must always be
   * invoked before calling `completeCallback` for processRecords. Moreover,
   * `completeCallback` should only be invoked once the checkpoint operation
   * callback is received.
   *
   * @param {object} processRecordsInput - Process records information with
   *             array of records that are to be processed. Looks like -
   *             {"records":[<record>, <record>], "checkpointer":<Checkpointer>}
   *             where <record> format is specified above.
   * @param {callback} completeCallback - The callback that must be invoked
   *             once all records are processed and checkpoint (optional) is
   *             complete.
   */
  processRecords: function(processRecordsInput, completeCallback) {
    if (!processRecordsInput || !processRecordsInput.records) {
      // Must call completeCallback to proceed further.
      completeCallback();
      return;
    }

    var records = processRecordsInput.records;
    var record, sequenceNumber, partitionKey, data;
    for (var i = 0 ; i < records.length ; ++i) {
      record = records[i];
      sequenceNumber = record.sequenceNumber;
      partitionKey = record.partitionKey;
      // Note that "data" is a base64-encoded string. Buffer can be used to
      // decode the data into a string.
      data = new Buffer(record.data, 'base64').toString();

      // Custom record processing logic ...
    }
    if (!sequenceNumber) {
      // Must call completeCallback to proceed further.
      completeCallback();
      return;
    }
    // If checkpointing, only call completeCallback once checkpoint operation
    // is complete.
    processRecordsInput.checkpointer.checkpoint(sequenceNumber,
      function(err, checkpointedSequenceNumber) {
        // In this example, regardless of error, we mark processRecords
        // complete to proceed further with more records.
        completeCallback();
      }
    );
  },

  /**
  * Called by the KCL to indicate that this record processor should shut down.
  * After the lease lost operation is complete, there will not be any more calls to
  * any other functions of this record processor. Clients should not attempt to
  * checkpoint because the lease has been lost by this Worker.
  * 
  * @param {object} leaseLostInput - Lease lost information.
  * @param {callback} completeCallback - The callback must be invoked once lease
  *               lost operations are completed.
  */
  leaseLost: function(leaseLostInput, completeCallback) {
    // Lease lost logic ...
    completeCallback();
  },

  /**
  * Called by the KCL to indicate that this record processor should shutdown.
  * After the shard ended operation is complete, there will not be any more calls to
  * any other functions of this record processor. Clients are required to checkpoint
  * at this time. This indicates that the current record processor has finished
  * processing and new record processors for the children will be created.
  * 
  * @param {object} shardEndedInput - ShardEnded information. Looks like -
  *               {"checkpointer": <Checpointer>}
  * @param {callback} completeCallback - The callback must be invoked once shard
  *               ended operations are completed.
  */
  shardEnded: function(shardEndedInput, completeCallback) {
    // Shard end logic ...
    
    // Since you are checkpointing, only call completeCallback once the checkpoint
    // operation is complete.
    shardEndedInput.checkpointer.checkpoint(function(err) {
      // In this example, regardless of the error, we mark the shutdown operation
      // complete.
      completeCallback();
    });
    completeCallback();
  }
};

kcl(recordProcessor).run();

Before You Get Started

Prerequisite

Before you begin, Node.js and NPM must be installed on your system. For download instructions for your platform, see http://nodejs.org/download/.

To get the sample KCL application and bootstrap script, you need git.

Amazon KCL for Node.js uses MultiLangDaemon provided by Amazon KCL for Java. You also need Java version 1.8 or higher installed.

Setting Up the Environment

Before running the samples, make sure that your environment is configured to allow the samples to use your AWS Security Credentials, which are used by MultiLangDaemon to interact with AWS services.

By default, the MultiLangDaemon uses the DefaultAWSCredentialsProviderChain, so make your credentials available to one of the credentials providers in that provider chain. There are several ways to do this. You can provide credentials through a ~/.aws/credentials file or through environment variables (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY). If you're running on Amazon EC2, you can associate an IAM role with your instance with appropriate access.

For more information about Amazon Kinesis and the client libraries, see the Amazon Kinesis documentation as well as the Amazon Kinesis forums.

Running the Sample

The Amazon KCL for Node.js repository contains source code for the KCL, a sample data producer and data consumer (processor) application, and the bootstrap script.

To run sample applications, you need to get all required NPM modules. From the root of the repository, execute the following command:

npm install

This downloads all dependencies for running the bootstrap script as well as the sample application.

The sample application consists of two components:

  • A data producer (samples/basic_sample/producer/sample_kinesis_producer_app.js): this script creates an Amazon Kinesis stream and starts putting 10 random records into it.
  • A data processor (samples/basic_sample/consumer/sample_kcl_app.js): this script is invoked by the MultiLangDaemon, consumes the data from the Amazon Kinesis stream, and stores received data into files (1 file per shard).

The following defaults are used in the sample application:

  • Stream name: kclnodejssample
  • Number of shards: 2
  • Amazon KCL application name: kclnodejssample
  • Amazon DynamoDB table for Amazon KCL application: kclnodejssample

Running the Data Producer

To run the data producer, execute the following commands from the root of the repository:

    cd samples/basic_sample/producer
    node sample_kinesis_producer_app.js

Notes

  • The script samples/basic_sample/producer/sample_kinesis_producer_app.js takes several parameters that you can use to customize its behavior. To change default parameters, change values in the file samples/basic_sample/producer/config.js.

Running the Data Processor

To start the data processor, run the following command from the root of the repository:

    cd samples/basic_sample/consumer
    ../../../bin/kcl-bootstrap --java /usr/bin/java -e -p ./sample.properties

Notes

  • The Amazon KCL for Node.js uses stdin/stdout to interact with MultiLangDaemon. Do not point your application logs to stdout/stderr. If your logs point to stdout/stderr, log output gets mingled with MultiLangDaemon, which makes it really difficult to find consumer-specific log events. This consumer uses a logging library to redirect all application logs to a file called application.log. Make sure to follow a similar pattern while developing consumer applications with the Amazon KCL for Node.js. For more information about the protocol between the MultiLangDaemon and the Amazon KCL for Node.js, go to MultiLangDaemon.
  • The bootstrap script downloads MultiLangDaemon and its dependencies.
  • The bootstrap script invokes the MultiLangDaemon, which starts the Node.js consumer application as its child process. By default:
    • The file samples/basic_sample/consumer/sample.properties controls which Amazon KCL for Node.js application is run. You can specify your own properties file with the -p or --properties argument.
    • The bootstrap script uses JAVA_HOME to locate the java binary. To specify your own java home path, use the -j or --java argument when invoking the bootstrap script.
  • To only print commands on the console to run the KCL application without actually running the KCL application, leave out the -e or --execute argument to the bootstrap script.
  • You can also add REPOSITORY_ROOT/bin to your PATH so you can access kcl-bootstrap from anywhere.
  • To find out all the options you can override when running the bootstrap script, run the following command:
    kcl-bootstrap --help

Cleaning Up

This sample application creates an Amazon Kinesis stream, sends data to it, and creates a DynamoDB table to track the KCL application state. This will incur nominal costs to your AWS account, and continue to do so even when the sample app is finished. To stop being charged, delete these resources. Specifically, the sample application creates following AWS resources:

  • An Amazon Kinesis stream named kclnodejssample
  • An Amazon DynamoDB table named kclnodejssample

You can delete these using the AWS Management Console.

Running on Amazon EC2

Log into an Amazon EC2 instance running Amazon Linux, then perform the following steps to prepare your environment for running the sample application. Note the version of Java that ships with Amazon Linux can be found at /usr/bin/java and should be 1.8 or greater.

    # install node.js, npm and git
    sudo yum install nodejs npm --enablerepo=epel
    sudo yum install git
    # clone the git repository to work with the samples
    git clone https://github.com/awslabs/amazon-kinesis-client-nodejs.git kclnodejs
    cd kclnodejs/samples/basic_sample/producer/
    # download dependencies
    npm install
    # run the sample producer
    node sample_kinesis_producer_app.js &

    # ...and in another terminal, run the sample consumer
    export PATH=$PATH:kclnodejs/bin
    cd kclnodejs/samples/basic_sample/consumer/
    kcl-bootstrap --java /usr/bin/java -e -p ./sample.properties > consumer.out 2>&1 &

NPM module

To get the Amazon KCL for Node.js module from NPM, use the following command:

  npm install aws-kcl

Under the Hood: Supplemental information about the MultiLangDaemon

Amazon KCL for Node.js uses Amazon KCL for Java internally. We have implemented a Java-based daemon, called the MultiLangDaemon that does all the heavy lifting. The daemon launches the user-defined record processor script/program as a sub-process, and then communicates with this sub-process over standard input/output using a simple protocol. This allows support for any language. This approach enables the Amazon KCL to be language-agnostic, while providing identical features and similar parallel processing model across all languages.

At runtime, there will always be a one-to-one correspondence between a record processor, a child process, and an Amazon Kinesis shard. The MultiLangDaemon ensures that, without any developer intervention.

In this release, we have abstracted these implementation details away and exposed an interface that enables you to focus on writing record processing logic in Node.js.

See Also

Release Notes

Release 2.2.6 (April 25, 2024)

  • PR #327 Upgraded amazon-kinesis-client from 2.5.5 to 2.5.8
  • PR #329 Upgraded aws-sdk from 2.1562.0 to 2.1603.0
  • PR #95 Upgraded jcommander from 1.72 to 1.82
  • PR #271 Upgraded org.codehaus.mojo:animal-sniffer-annotations from 1.20 to 1.23
  • PR #266 Upgraded com.amazonaws:aws-java-sdk-core from 1.12.370 to 1.12.512
  • PR #313 Upgraded logback.version from 1.3.12 to 1.5.3
  • PR #305 Upgraded org.slf4j:slf4j-api from 2.0.5 to 2.0.12
  • PR #325 Upgraded mocha from 9.2.2 to 10.4.0
  • PR #307 Upgraded com.google.protobuf:protobuf-java from 3.21.7 to 3.25.3
  • PR #262 Upgraded checker-qual from 2.5.2 to 3.36.0
  • PR #303 Upgraded commander from 8.3.0 to 12.0.0
  • PR #287 Upgraded sinon from 14.0.2 to 17.0.1
  • PR #318 Upgraded awssdk.version from 2.20.43 to 2.25.11
  • PR #319 Upgraded org.reactivestreams:reactive-streams from 1.0.3 to 1.0.4
  • PR #320 Upgraded netty-reactive.version from 2.0.6 to 2.0.12
  • PR #330 Upgraded io.netty:netty-codec-http from 4.1.100.Final to 4.1.108.Final
  • PR #331 Upgraded ion-java from 1.5.1 to 1.11.4
  • PR #211 Upgraded fasterxml-jackson.version from 2.13.4 to 2.14.1

Release 2.2.5 (February 29, 2024)

  • PR #309 Updated amazon-kinesis-client and amazon-kinesis-client multilang from 2.5.4 to 2.5.5 and updated awssdk.version to match amazon-kinesis-client from 2.19.2 to 2.20.43

Release 2.2.4 (January 16, 2024)

  • PR #298 Added dependency on aws-sdk arns
  • PR #293 Updated logback-classic to 1.3.12

Release 2.2.3 (December 18, 2023)

  • PR #291 Updated KCL and KCL multilang to the latest version 2.5.4
  • PR #284 Updated netty to 4.1.100.Final, fasterxml-jackson to 2.13.5, and guava to 32.1.1-jre
  • PR #277 Updated com.google.protobuf:protobuf-java from 3.21.5 to 3.21.7

Release 2.2.2 (January 4, 2023)

  • PR #207 Add endpoints-spi dependency

Release 2.2.1 (January 3, 2023)

  • PR #202 Keep Java dependencies in sync with the KCL V2.4.4
    • Updated dependencies to match the v2.4.4 KCL Java release
    • Updated slfj to resolve the logger's incompatibility problem

Release 2.2.0 (September 15, 2022)

  • PR #165 Update Java dependencies
    • KCL and KCL-multilang are updated to the latest version 2.4.3

Release 2.1.0 (January 31, 2020)

Milestone #4

  • Fixing bootstrap to use HTTPS
  • Adding support for Win32 platform
  • Relicensing to Apache-2.0

Release 2.0.0 (March 6, 2019)

  • Added support for Enhanced Fan-Out.
    Enhanced Fan-Out provides dedicated throughput per stream consumer, and uses an HTTP/2 push API (SubscribeToShard) to deliver records with lower latency.
  • Updated the Amazon Kinesis Client Library for Java to version 2.1.2.
  • Added support for the newer methods to the KCLManager.
    While the original shutdown method will continue to work it's recommended to upgrade to the newer interface.
    • The shutdown has been replaced by leaseLost and shardEnded.
    • Added the leaseLost method which is invoked when a lease is lost.
      leaseLost replaces shutdown where shutdownInput.reason was ZOMBIE.
    • Added the shardEnded method which is invoked when all records from a split or merge have been processed.
      shardEnded replaces shutdown where shutdownInput.reason was TERMINATE.
  • Updated the AWS Java SDK version to 2.4.0
  • MultiLangDaemon now provides logging using Logback.
    • MultiLangDaemon supports custom configurations for logging via a Logback XML configuration file.
    • The kcl-bootstrap program was been updated to accept either -l or --log-configuration to provide a Logback XML configuration file.

Release 0.8.0 (February 12, 2019)

  • Updated the dependency on Amazon Kinesis Client for Java to 1.9.3
    • This adds support for ListShards API. This API is used in place of DescribeStream API to provide more throughput during ShardSyncTask. Please consult the AWS Documentation for ListShards for more information.
      • ListShards supports higher call rate, which should reduce instances of throttling when attempting to synchronize the shard list.
      • WARNING: ListShards is a new API, and may require updating any explicit IAM policies
    • PR #59
  • Changed to now download jars from Maven using https.

Release 0.7.0 (August 2, 2017)

  • Updated the dependency on Amazon Kinesis Client for Java to 1.8.1.
    This adds support for setting a timeout when dispatching records to the node.js record processor. If the record processor doesn't respond in the given time the Java processor is terminated. The timeout for the this can be set by adding timeoutInSeconds = <timeout value>. The default for this is no timeout.
    Setting this can cause the KCL to exit suddenly, before using this ensure that you have an automated restart for your application
    Updating minimum requirement for the JDK version to 8
  • Added support to handle graceful shutdown requests.

Release 0.6.0 (December 12, 2016)

Release 0.5.0 (March 26, 2015)

  • The aws-kcl npm module allows implementation of record processors in Node.js using the Amazon KCL MultiLangDaemon.
  • The samples directory contains a sample producer and processing applications using the Amazon KCL for Node.js.

License

This library is licensed under the Apache 2.0 License.

amazon-kinesis-client-nodejs's People

Contributors

brendan-p-lynch avatar cory-bradshaw avatar dependabot[bot] avatar hyandell avatar joshua-kim avatar joshuamorris3 avatar jpeddicord avatar lucienlu-aws avatar nezetic avatar nunoh avatar omri-s-electreon avatar pawellabudafitit avatar pfifer avatar rutvih avatar sahilpalvia avatar tomafc330 avatar zengyu714 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-kinesis-client-nodejs's Issues

processRecords with async operations?

Decided to use the new basic consumer sample as a template for my current processor..

So on this project, we have some asynchronous tasks to do for each kinesis message, we also want to checkpoint after each message. Was wondering if you could take a peek at my processRecords impl to see if it looks solid:

fyi to decouple a lot of our processing and retry logic from the consumer we pass a recordProcessingStrategyCallback to the consumer.. @sahilpalvia

'use strict';

var util = require('util');

module.exports = function strategizedKinesisConsumer(logger, recordProcessingStrategyCallback) {

  var shardId;
  var logger = logger;
  var recordProcessingStrategyCallback = recordProcessingStrategyCallback;

  return {

    initialize: function(initializeInput, completeCallback) {
      shardId = initializeInput.shardId;

      logger.info('strategizedKinesisConsumer', {customText: `New KCL consumer initializing with config: ${JSON.stringify(initializeInput)}`});

      completeCallback();
    },

    processRecords: function(processRecordsInput, completeCallback) {
      
      if (!processRecordsInput || !processRecordsInput.records) {
        completeCallback();
        return;
      }

      var records = processRecordsInput.records;
      
      return new Promise( async (resolve, reject) => {

        for (var i = 0 ; i < records.length ; ++i) {
          let record = records[i];
          let data = new Buffer(record.data, 'base64').toString();
          let dataObj = JSON.parse(data);
          let sequenceNumber = record.sequenceNumber;
          let partitionKey = record.partitionKey;
          
          logger.info(util.format('ShardID: %s, Record: %s, SeqenceNumber: %s, PartitionKey:%s', shardId, data, sequenceNumber, partitionKey));

          //call logic
          logger.info('event', {eventId: dataObj.eventId, correlationId: dataObj.correlationId, customText: 'Delegating message to blackbox strategy for processing'});
          await recordProcessingStrategyCallback(dataObj);
          logger.info('event', {eventId: dataObj.eventId, correlationId: dataObj.correlationId, customText: '...back from blackbox strategy'});

          if (!sequenceNumber) {
            completeCallback();
            return;
          }

          const checkpoint = util.promisify(processRecordsInput.checkpointer.checkpoint).bind(processRecordsInput.checkpointer);

          logger.info('event', {eventId: dataObj.eventId, correlationId: dataObj.correlationId, customText: 'Checkpointing message...'});
          await checkpoint(sequenceNumber);
          logger.info('event', {eventId: dataObj.eventId, correlationId: dataObj.correlationId, customText: '..message checkpointed'});
  
        
        }

        completeCallback()
        
        resolve()

      });  
    },

    leaseLost: function(leaseLostInput, completeCallback) {
     ...
    },

    shardEnded: function(shardEndedInput, completeCallback) {
     ..
    },

    shutdownRequested: function(shutdownRequestedInput, completeCallback) {
      ..
    }
  };
}  

upgrade to kcl 2.0

Can you provide an implementation with the most recent kcl version (2.0)?

Zombie nodejs processes

After KCL is working long time I see zombie nodejs processes which don't do anything. KCL starts new nodejs processes, but don't kill zombie processes.
Is anybody receive this problem?

Error when updating to aws-kcl 2.0.0 unrecognized classpath option "-cp"

==========================================================
Starting MultiLangDaemon ...
Unrecognized option: -cp "/var/app/current/node_modules/aws-kcl/lib/jars/amazon-kinesis-client-2.1.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/amazon-kinesis-client-multilang-2.1.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/animal-sniffer-annotations-1.14.jar:/var/app/current/node_modules/aws-kcl/lib/jars/annotations-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/apache-client-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/auth-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/aws-cbor-protocol-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/aws-core-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/aws-java-sdk-core-1.11.477.jar:/var/app/current/node_modules/aws-kcl/lib/jars/aws-json-protocol-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/aws-query-protocol-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/checker-qual-2.5.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/cloudwatch-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/commons-beanutils-1.9.3.jar:/var/app/current/node_modules/aws-kcl/lib/jars/commons-codec-1.10.jar:/var/app/current/node_modules/aws-kcl/lib/jars/commons-collections-3.2.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/commons-collections4-4.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/commons-io-2.6.jar:/var/app/current/node_modules/aws-kcl/lib/jars/commons-lang3-3.8.1.jar:/var/app/current/node_modules/aws-kcl/lib/jars/commons-logging-1.1.3.jar:/var/app/current/node_modules/aws-kcl/lib/jars/dynamodb-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/error_prone_annotations-2.1.3.jar:/var/app/current/node_modules/aws-kcl/lib/jars/flow-1.7.jar:/var/app/current/node_modules/aws-kcl/lib/jars/guava-26.0-jre.jar:/var/app/current/node_modules/aws-kcl/lib/jars/http-client-spi-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/httpclient-4.5.6.jar:/var/app/current/node_modules/aws-kcl/lib/jars/httpcore-4.4.10.jar:/var/app/current/node_modules/aws-kcl/lib/jars/ion-java-1.0.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/j2objc-annotations-1.1.jar:/var/app/current/node_modules/aws-kcl/lib/jars/jackson-annotations-2.9.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/jackson-core-2.9.8.jar:/var/app/current/node_modules/aws-kcl/lib/jars/jackson-databind-2.9.8.jar:/var/app/current/node_modules/aws-kcl/lib/jars/jackson-dataformat-cbor-2.9.8.jar:/var/app/current/node_modules/aws-kcl/lib/jars/jcommander-1.72.jar:/var/app/current/node_modules/aws-kcl/lib/jars/joda-time-2.8.1.jar:/var/app/current/node_modules/aws-kcl/lib/jars/jsr305-3.0.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/kinesis-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/logback-classic-1.2.3.jar:/var/app/current/node_modules/aws-kcl/lib/jars/logback-core-1.2.3.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-buffer-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-codec-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-codec-http-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-codec-http2-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-common-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-handler-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-nio-client-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-reactive-streams-2.0.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-reactive-streams-http-2.0.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-resolver-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-transport-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-transport-native-epoll-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/netty-transport-native-unix-common-4.1.32.Final.jar:/var/app/current/node_modules/aws-kcl/lib/jars/profiles-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/protobuf-java-2.6.1.jar:/var/app/current/node_modules/aws-kcl/lib/jars/protocol-core-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/reactive-streams-1.0.2.jar:/var/app/current/node_modules/aws-kcl/lib/jars/regions-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/rxjava-2.1.14.jar:/var/app/current/node_modules/aws-kcl/lib/jars/sdk-core-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/slf4j-api-1.7.25.jar:/var/app/current/node_modules/aws-kcl/lib/jars/sts-2.4.0.jar:/var/app/current/node_modules/aws-kcl/lib/jars/utils-2.4.0.jar:/var/app/current:/var/app/current"
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Update npm package

Hello,

When pulling the npm package, it pulls the 0.5.0 tag by default which contains an out of date /bin/kcl-bootstrap file. The dependecies were recently updated so it would be nice if you could update the package to pull the latest code.

Thank you

Is it possible for KCL to drop records?

Tried asking on StackOverflow but got no answer, perhaps one of the core maintainers can comment.

Basically AWS docs say that there are times where KCL can drop records if it receives an error. Whichever way we crash our node app, it just restarts with the same checkpoint as before, thus not dropping records.

What's the scenario where it can drop records? How do we replicate it? For our application it's paramount we don't, so if that scenario exists need to build in protection.

PS note we're already handling failures on the producer side, this is for the consumer specifically.

Would really appreciate feedback ๐Ÿ™

Unable to locate java

when I run the command

kcl-bootstrap -e -p ..\samples\basic_sample\consumer\sample.properties

from the location of the bootstrap file, I get:
ERROR: Valid --java value is required or alternatively JAVA_HOME environment must be set.

I have set the JAVA_HOME value to point to my java.exe file, and have added the --java [path-to-java] option to my command and still am unable to run the code

Error while running consumer

I am trying the to run the sample as it is, producer works fine but i am getting errors while running the consumer:
Here is the console dump:
Apr 24, 2018 2:55:02 PM com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker info
INFO: Current stream shard assignments: shardId-000000000001, shardId-000000000000
Apr 24, 2018 2:55:02 PM com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker info
INFO: Sleeping ...
Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.LineReaderTask call
INFO: Stopping: Reading next message from STDIN for shardId-000000000000
Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.LineReaderTask call
INFO: Stopping: Reading STDERR for shardId-000000000000
Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.MultiLangProtocol futureMethod
SEVERE: Failed to get status message for initialize action for shard shardId-000000000000
java.util.concurrent.ExecutionException: java.lang.RuntimeException: Reached end of STDIN of child process for shard shardId-000000000000 so won't be able to return a message.
at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
at com.amazonaws.services.kinesis.multilang.MultiLangProtocol.futureMethod(MultiLangProtocol.java:197)
at com.amazonaws.services.kinesis.multilang.MultiLangProtocol.waitForStatusMessage(MultiLangProtocol.java:171)
at com.amazonaws.services.kinesis.multilang.MultiLangProtocol.waitForStatusMessage(MultiLangProtocol.java:138)
at com.amazonaws.services.kinesis.multilang.MultiLangProtocol.initialize(MultiLangProtocol.java:78)
at com.amazonaws.services.kinesis.multilang.MultiLangRecordProcessor.initialize(MultiLangRecordProcessor.java:94)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitializeTask.call(InitializeTask.java:90)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.MetricsCollectingTaskDecorator.call(MetricsCollectingTaskDecorator.java:49)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.MetricsCollectingTaskDecorator.call(MetricsCollectingTaskDecorator.java:24)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Reached end of STDIN of child process for shard shardId-000000000000 so won't be able to return a message.
at com.amazonaws.services.kinesis.multilang.GetNextMessageTask.returnAfterEndOfInput(GetNextMessageTask.java:84)
at com.amazonaws.services.kinesis.multilang.GetNextMessageTask.returnAfterEndOfInput(GetNextMessageTask.java:31)
at com.amazonaws.services.kinesis.multilang.LineReaderTask.call(LineReaderTask.java:70)
... 4 more

Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.MultiLangRecordProcessor stopProcessing
SEVERE: Encountered an error while trying to initialize record processor
java.lang.RuntimeException: Failed to initialize child process
at com.amazonaws.services.kinesis.multilang.MultiLangRecordProcessor.initialize(MultiLangRecordProcessor.java:95)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitializeTask.call(InitializeTask.java:90)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.MetricsCollectingTaskDecorator.call(MetricsCollectingTaskDecorator.java:49)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.MetricsCollectingTaskDecorator.call(MetricsCollectingTaskDecorator.java:24)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.LineReaderTask call
INFO: Starting: Draining STDOUT for shardId-000000000000
Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.LineReaderTask call
INFO: Stopping: Draining STDOUT for shardId-000000000000
Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.MultiLangRecordProcessor childProcessShutdownSequence
INFO: Child process exited with value: 1
Apr 24, 2018 2:55:15 PM com.amazonaws.services.kinesis.multilang.MultiLangDaemon run
INFO: Process terminanted, will initiate shutdown.

How to catch KCL error

Hello,
I'm using KCL in nodeJS to send data from kinesis to some other streams in my app (for example websocket), first thing i do is initialiation of websocket connection, i want to be able to close connection when KCL initialization fails or when some errors occurs. Is it possible to register some handler in child process or listening on some message to be notified about errors?

For now i'm using uncaughtException to gracefully disable my connections but maybe it is another way ?

Error when running the basic producer sample

When I run the basic producer sample according to the docs, I get this error:

/Users/ttt/repo/ratingbutler/kinesis/amazon-kinesis-client-nodejs/node_modules/aws-sdk/lib/request.js:31
            throw err;
            ^

TypeError: "callback" argument must be a function
    at exports.setTimeout (timers.js:327:11)
    at /Users/ttt/repo/ratingbutler/kinesis/amazon-kinesis-client-nodejs/samples/basic_sample/producer/sample_producer.js:101:11

The offending line is in 101 where the pass in param is not a function. I will open a PR to address this.

KCL consumer on kubernetes does not pick up IAM role via serviceAccount.

Deploying KCL consumer via kubernetes on aws EKS service does not pick up IAM role from serviceAccount with AWSCredentialsProvider = DefaultAWSCredentialsProviderChain, instead it uses node level role.

Following environment variables are present in the service, however it still doesn't seem to pick it up. However it works when I provide AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

AWS_DEFAULT_REGION=<region>
AWS_REGION=<region>
AWS_ROLE_ARN=<role-arn>
AWS_WEB_IDENTITY_TOKEN_FILE=<token-path>

Can not run the sample.

I`m trying to run KCL with localstack

Always getting:
Caused by: io.netty.handler.codec.http2.Http2Exception: First received frame was not SETTINGS. Hex dump for first 5 bytes: 3c21444f43

Graceful Shutdown of Workers

Since September 30, 2016, there's a new method in KCL's library (for Java) that handles very well the shutdown. Its called "requestShutdown", and it has already been implemented there.

awslabs/amazon-kinesis-client#109

We are missing that method here in Node... when KCL decides to shutdown a worker, how can we handle and perform a Graceful Shutdown? Meaning that would be cool to let the worker to finish processing the current batch, then checkpoint, and only then start the shutdown.

Customizing log level

In the default configuration, the system generates extremely verbose logs.

Is it possible to adjust the log level downwards by editing the application.properties file somehow?

Consuming multiple streams using KCL

Hi I have an application that consuming multiple streams by starting several KCL processes, which works fine, but when the application is interrupted rather than an exception raised from my record processor those multiple instances of MultiLangDaemon will continue running, which causes problems.

When I restart the application a new set of MultiLangDaemon processes will be started and from this point on wards I am running into situation in which:

  • either the DynamoDB table will contain a different worker ID i.e leaseOwner than my newly started worker's ID so nothing will happen,
  • Or I can possibly alter the table and betting on MultiLangDaemon to repopulate the table with new leaseOwner ID but eventually the host machine will have many "java.exe" processes running and run out of memory.

I can stop those multiple node-js KCL bootstrap processes by executing OS commands in my application but I don't know how to ONLY stop MultiLangDaemon processes (they are just java.exe on windows).

All these can be resolved "relatively properly", if I can stop the MultiLangDaemon process, hence when new MultiLangDaemon process start the leaseOwner ID will be changed and the process starts normally and the machine won't run out of memory. (I can't just kill all "java.exe" on windows or java on Unix system)

You suggestion and help will be much appreciated !

Can we specify the nodejs version we want to use

I notice that we specify the language in the configuration as such

# Appended to the user agent of the KCL. Does not impact the functionality of the
# KCL in any other way.
processingLanguage = nodejs/0.10

If i I have nopdejs v4.2.1 installed how am i able to specify that in the configuration file.

Memory leak when writing intensively

I have a memory leak problem writing to kinesis from node and I wanted to verify if it happens as well with this sample producer.

I verified that if instead of 10 writes, you modify the code to write endlessly 10 times per second, the memory consumption grows slowly but steadily.

Any idea why this happens?

Native only

Why java daemon.. it's like having to speak English, I need a Greek translator.. bad approach:(

Cannot find module 'log4js'

After npm install, I tried to run the producer, I got this error:

Error: Cannot find module 'log4js'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/src/app/samples/util/logger.js:18:14)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

So, what's wrong?

Empty S3 Bucket Name

Sorry, maybe I didn't fully understand the application, but perhaps it would be better to states in README that S3 Bucket Name is required when using the CloudFormation template associated with the clickStream example, or remove the S3 Bucket from the template so that the stack creation will not fail. It will be created by the application anyway.

SEVERE: class FastBuffer extends Uint8Array {}]

Used the KPL to ingest data and got this one:

INFO: Starting: Reading next message from STDIN for shardId-000000000017
Jul 11, 2017 9:05:28 PM com.amazonaws.services.kinesis.multilang.MessageWriter call
INFO: Message size == 719833 bytes for shard shardId-000000000017
Jul 11, 2017 9:05:28 PM com.amazonaws.services.kinesis.multilang.DrainChildSTDERRTask handleLine
SEVERE: Received error line from subprocess [buffer.js:8] for shard shardId-000000000017
buffer.js:8
Jul 11, 2017 9:05:28 PM com.amazonaws.services.kinesis.multilang.DrainChildSTDERRTask handleLine
SEVERE: Received error line from subprocess [class FastBuffer extends Uint8Array {}] for shard shardId-000000000017
class FastBuffer extends Uint8Array {}
Jul 11, 2017 9:05:28 PM com.amazonaws.services.kinesis.multilang.DrainChildSTDERRTask handleLine
SEVERE: Received error line from subprocess [^] for shard shardId-000000000017
Jul 11, 2017 9:05:28 PM com.amazonaws.services.kinesis.multilang.DrainChildSTDERRTask handleLine
SEVERE: Received error line from subprocess [] for shard shardId-000000000017
Jul 11, 2017 9:05:28 PM com.amazonaws.services.kinesis.multilang.DrainChildSTDERRTask handleLine
SEVERE: Received error line from subprocess [RangeError: Maximum call stack size exceeded] for shard shardId-000000000017
RangeError: Maximum call stack size exceeded
Jul 11, 2017 9:05:28 PM com.amazonaws.services.kinesis.multilang.DrainChildSTDERRTask handleLine
SEVERE: Received error line from subprocess [ at Buffer.Uint8Array (native)] for shard shardId-000000000017
at Buffer.Uint8Array (native)

my dependencies:
"dependencies": {
"async": "^2.4.1",
"aws-kinesis-agg": "^2.2.2",
"aws-sdk": "^2.79.0",
"aws-xray-sdk": "^1.1.1",
"requestretry": "^1.12.0",
"util": "^0.10.3",
"uuid": "^3.1.0",
"winston": "^2.3.1",
"aws-kcl": "^0.6.0"
},

Record processor not shutdown on IO close

I received an uncaught exception that meant the consumer was no longer connected to Kinesis. In this case, I would imagine that the KCL would either continuously attempt to reconnect or die and call shutdown. However, neither happened, which got my consumer process stuck in an invalid and dangerous state: thinking it was connected when it wasn't.

Stack trace:

Error: Kinesis Client Library is in the invalid state. Cannot proceed further.
  File "/vitally/server/node_modules/aws-kcl/lib/kcl/kcl_manager.js", line 399, col 11, in KCLManager._handleStateInput
    throw new Error('Kinesis Client Library is in the invalid state. Cannot proceed further.');
  File "/vitally/server/node_modules/aws-kcl/lib/kcl/kcl_manager.js", line 265, col 8, in KCLManager._onActionEnd
    this._handleStateInput(this._context, 'cleanup');
  File "events.js", line 106, col 13, in emitNone
  File "events.js", line 208, col 7, in ActionHandler.emit
  File "/vitally/server/node_modules/aws-kcl/lib/kcl/action_handler.js", line 82, col 8, in ActionHandler._onIOClose
    this.emit('end');
  File "events.js", line 106, col 13, in emitNone
  File "events.js", line 208, col 7, in IOHandler.emit
  File "/vitally/server/node_modules/aws-kcl/lib/kcl/io_handler.js", line 93, col 8, in IOHandler._onInputClose
    this.emit('close');
  File "events.js", line 111, col 20, in emitNone
  File "events.js", line 208, col 7, in Interface.emit
  File "readline.js", line 370, col 8, in Interface.close
  File "readline.js", line 149, col 10, in Socket.onend
  File "events.js", line 111, col 20, in emitNone
  File "events.js", line 208, col 7, in Socket.emit
  File "_stream_readable.js", line 1055, col 12, in endReadableNT
  File "internal/process/next_tick.js", line 138, col 11, in _combinedTickCallback
  File "internal/process/next_tick.js", line 218, col 9, in process._tickDomainCallback

run consumer as background service

I have been trying to use it as background service on ubuntu 16.06. absolute paths gives exception
/home/ubuntu/kcl/bin/kcl-bootstrap --java /usr/bin/java -e -p /home/ubuntu/kcl/samples/basic_sample/consumer/sample.properties -s
results in

Starting Multi-Lang Daemon ...
Exception in thread "main" java.lang.NullPointerException
        at java.util.Properties$LineReader.readLine(Properties.java:434)
        at java.util.Properties.load0(Properties.java:353)
        at java.util.Properties.load(Properties.java:341)
        at com.amazonaws.services.kinesis.multilang.MultiLangDaemonConfig.loadProperties(MultiLangDaemonConfig.java:135)
        at com.amazonaws.services.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:85)
        at com.amazonaws.services.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:70)
        at com.amazonaws.services.kinesis.multilang.MultiLangDaemonConfig.<init>(MultiLangDaemonConfig.java:57)

also tried with /etc/init.d/ and changed directory to consumer folder and ran ../../../bin/kcl-bootstrap --java /usr/bin/java -e -p ./sample.properties -s

is there any way I can run it as background service (relaunch if it crashes and start on boot)
thanks for any help

High CPU usage with node

Hi aws team!

I'm running the KCL client for reading 10 shards.
It seems like the for some simple log operations, each process take up to 45% cpu usage on a m3.xlarge. I was wondering if that was normal, or if I'm missing anything ?

Thank you for your insights

kcl-bootstrap can't download dependencies on Maven repository

The kcl-bootstrap script can't download dependencies on Maven repository anymore.

The root cause is pretty straight forward (and frightening): the script does not respect the URL scheme, and never use https while downloading dependencies.

The issue raised because Maven repository does not accept http requests anymore.

I submitted a PR solving this #75

Proper way to implement processRecord retries

I am wondering what the proper way to implement retry logic in the processRecords function that will attempt (indefinitely) to reprocess records from a checkpointed sequence number.

For example, in our KCL application, in the processRecord function, we do some processing on the record data and then send the result via TCP to another service. If for some reason that service is down, we do not want to continue processing subsequent records but rather continue to retry processing the same record until it succeeds. In this scenario there is no issue with the data, it's just that we aren't able to push the processed data to it's desired destination.

From testing I've discovered that within the processRecord function, even if completeCallback() is called without calling checkpoint(), the KCL will still attempt to grab the next record and not retry the previous record that failed to be "processed". But, I've also noticed that if completeCallback() is called without calling checkpoint() and the KCL application is restarted, then it will start again from after the last checkpoint, thus retrying the records that failed to "process".

So by this, it seems that in order to implement retry logic, we should be stopping the KCL application and restarting it. Is there a recommended way to do that? In the java KCL library I noticed there is a worker.requestShutdown() method, but I don't see that in the Nodejs library, is it just a feature that hasn't been implemented yet? Either way, is the suggested work around to just do a process.exit() call when we want to retry (and having something watch the process that restarts it)? That seems like it may not be the best in regards to graceful a shutdown, is there a better way?

I believe this is related to the conversation here awslabs/amazon-kinesis-client#10

Cannot change the Credentials Provider

In the sample.properties fie, I added a different credentials Provider:
"AWSCredentialsProvider = EnvironmentVariableCredentialsProvider".
I have also set the Environment variable with correct credentials
When I run the consumer, it errors out with ::

java.util.concurrent.ExecutionException: com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.amazonaws.services.kinesis.multilang.MultiLangDaemon.main(MultiLangDaemon.java:217)
Caused by: com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain
at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:117)
at com.amazonaws.services.kinesis.multilang.MultiLangDaemon.prepare(MultiLangDaemon.java:123)
at com.amazonaws.services.kinesis.multilang.MultiLangDaemon.call(MultiLangDaemon.java:148)
at com.amazonaws.services.kinesis.multilang.MultiLangDaemon.call(MultiLangDaemon.java:61)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

missing java class when attempting to kick off the consumer in clickstream sample

Getting the following errors when executing the consumer in clickstream sample.

vagrant@vagrant:~/amazon-kinesis-client-nodejs/samples/click_stream_sample/consumer$ ~/amazon-kinesis-client-nodejs/bin/kcl-bootstrap --java /usr/bin/java -p ./sample.properties -e
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/commons-codec-1.3.jar downloaded. 9 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/joda-time-2.4.jar downloaded. 8 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/aws-java-sdk-1.7.13.jar downloaded. 7 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/jackson-databind-2.1.1.jar downloaded. 6 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/commons-logging-1.1.1.jar downloaded. 5 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/amazon-kinesis-client-1.2.0.jar downloaded. 4 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/jackson-core-2.1.1.jar downloaded. 3 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/httpclient-4.2.jar downloaded. 2 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/httpcore-4.2.jar downloaded. 1 files remain.
/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/jackson-annotations-2.1.1.jar downloaded. 0 files remain.
==========================================================
/usr/bin/java -cp /home/vagrant/amazon-kinesis-client-nodejs/lib/jars/amazon-kinesis-client-1.2.0.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/aws-java-sdk-1.7.13.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/commons-codec-1.3.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/commons-logging-1.1.1.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/httpclient-4.2.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/httpcore-4.2.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/jackson-annotations-2.1.1.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/jackson-core-2.1.1.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/jackson-databind-2.1.1.jar:/home/vagrant/amazon-kinesis-client-nodejs/lib/jars/joda-time-2.4.jar:/home/vagrant/amazon-kinesis-client-nodejs/samples/click_stream_sample/consumer:/home/vagrant/amazon-kinesis-client-nodejs/samples/click_stream_sample/consumer com.amazonaws.services.kinesis.multilang.MultiLangDaemon ./sample.properties
==========================================================
Starting Multi-Lang Daemon ...
Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentialsProvider
    at com.amazonaws.services.kinesis.clientlibrary.config.KinesisClientLibConfigurator.<init>(KinesisClientLibConfigurator.java:63)
    at com.amazonaws.services.kinesis.multilang.MultiLangDaemon.main(MultiLangDaemon.java:197)
Caused by: java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentialsProvider
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 2 more

Override dynamoDBEnpoint

Hi,

I'm running Localstack with Kinesis and DynamoDB locally, but I still don't know how to override DynamoDB endpoint. I was looking at the kinesis application client java library, but I guess it uses the default constructor to create the DynamoDbAsyncClient instance.

DynamoDbAsyncClient dynamoDBClient = DynamoDbAsyncClient.builder() .credentialsProvider(DefaultCredentialsProvider.create()).build();

Does anyone know how to do it?

Broken and outdated kcl-bootstrap - Here is an alternative

The kcl-bootstrap script is kinda broken. It downloads a hardcoded list of maven dependencies, when the package POM itself tells us what all dependencies are required. Also its really out of date. MultiLangDaemon is at version 1.6.1, whereas this library ships with 1.2.0

Here is a simple bootstrap script that you can copy/paste and run on your own. It first downloads Ivy, the uses Ivy to download the latest MultiLangDaemon JAR (plus all its dependencies properly) and runs it with the kcl properties file. Its actually very simple.

#!/usr/bin/env sh
# Usage:
# kcl.sh <path-to-kcl-properties>
# e.g.
# kcl.sh kcl.properties

MULTI_LANG_DAEMON_CLASS='com.amazonaws.services.kinesis.multilang.MultiLangDaemon'
IVY_URL='http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar'
mkdir -p kcl

if [ ! -f "kcl/ivy.jar" ]; then
  echo 'Downloading ivy...'
  wget -q $IVY_URL -O kcl/ivy.jar
fi

echo 'Downloading dependencies...'
java -jar kcl/ivy.jar \
     -dependency com.amazonaws amazon-kinesis-client 1.6.1 \
     -retrieve "kcl/[artifact]-[revision](-[classifier]).[ext]"

echo 'Starting KCL MultiLang daemon...'
java -cp .:"kcl/*" "$MULTI_LANG_DAEMON_CLASS" "$1"

Is there a way to use other credentials for dynamoDB?

The kinesis will be consumed by an user that hasn't dynamodb permissions.

So I need a way to create a dynamodb table in other aws account that has dynamodb permissions.

Is there a way to use two distincts credentials??

Not able to download MultiLangDaemon from maven repo

I'm receiving the following error when running the kcl-bootstrap script as following;

node kcl-bootstrap --java /usr/bin/java -e -p ../../../tests/sensor_datum_extra_field_node/kinesis.properties

ERROR: Unable to download Multi-Language Daemon jar files from maven: Error: connect ECONNREFUSED

using sudo did not change anything.

dynamodb-streams-kinesis-adapter?

Does this thing work with the DDB Streams Kinesis adapter? I am writing NodeJS worker. I need to process DDB streams. I am not finding any information about how this might be done using KCL. I might imagine that kcl-bootstrap needs to be modified to add getMavenPackageInfo('com.amazonaws', 'dynamodb-streams-kinesis-adapter', '1.0.0') in the MAVEN_PACKAGE_LIST and then in sample.properties, some way to identify the DDB stream ARN instead of a Kinesis stream name.

??

Is there any way to run some logic only on one child process?

I want to run my application which uses KCL to k8s cluster, i need some healthcheck endpoint and i want to use this library - https://github.com/gajus/lightship. But i have a problem because MultiLangDaemon runs three child processes and each one try to listen on some port, so application dies. Is there any way to run listen only in one child process (if this child is not healthy then whole app will be killed), or maybe i should do it in another way like configure many ports and each child process should use next port number (but how can i determine which child process i am when calling listen??)

Checkpoint Performance Cost?

I'm wondering what the cost of checkpoint is.

If I needed to checkpoint after each record in a batch, I'm curious if anyone knows if there will be a major performance impact or if it's a cheap operation.

Thanks!

Use a custom aws endpoint

I have a running localstack server, I want to update the sample.properties file to point to another endpoint, for example: http://localhost:4456
Can anyone help me?

Not able to send data from firehose to ES

In my project im streaming logs from cloudwatch kinesis stream. From kinesis stream i have linked to Kinesis firehose which invokes a lambda and transforms the data. The lambda code is one of the blueprints provided when we setup the firehose. I need to send data from firehose lambda to Elastic search as destination.

Now the problem is when i see the firehose logs in cloudwatch i get the below error:

{
"deliveryStreamARN": "arn:aws:firehose:us-east-2:620209065378:deliverystream/testSBFirehose",
"destination": "arn:aws:es:us-east-2:620209065378:domain/amcs-test",
"deliveryStreamVersionId": 2,
"message": "The ES cluster returned a JsonParseException. Ensure that the data being put is valid.",
"errorCode": "ES.JsonParseException",
"processor": "arn:aws:lambda:us-east-2:620209065378:function:streamCloudwatchLogsByKinesis:$LATEST"
}

Please let me know in which form/structure i need to send the data to ES from firehose lambda. Currently im sending data as below format:-

{
records: [
{
recordId:''some id",
result:"ok",
data:"base64 data",
}
]
}

Unable to run the consumer sample

I tried to run the kinesis click_stream_sample, the producer is working fine but the consumer has an issue.
The issue is that when I'm trying to run the command kcl-bootstrap <javapath> -e -p ./sample.properties I got this error: ERROR: Valid --java value is required or alternatively JAVA_HOME environment variable must be set. although I put the <javapath> with the my java path and also put JAVA_HOME in system variables so I can't determine why I have that problem till now.

Note: I'm trying this sample locally on my machine with Windows-10

@pfifer

listFragments return different FragmentLengthInMilliseconds then EXTINF

I'm trying to calculate my stream duration by using the list fragments API and then sum the FragmentLengthInMilliseconds for all the return fragments, however, the FragmentLengthInMilliseconds in the returned result is not the same as the time duration I get in the M3U file of the video, for example, the list of fragment I get for the following time range (Using PRODUCER_TIMESTAMP in both cases):

TimestampRange: {
      "StartTimestamp": "2022-01-28T07:00:35.000Z",
      "EndTimestamp": "2022-01-28T07:01:34.000Z"
    }

List of sorted fragments by ProducerTimestamp:

 [
  {
    FragmentNumber: '91343852333185057105875891022195998207386831087',
    FragmentSizeInBytes: 788604,
    ProducerTimestamp: 2022-01-28T07:00:35.931Z,
    ServerTimestamp: 2022-01-28T07:00:47.067Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057110827651179337519666762451998',
    FragmentSizeInBytes: 868779,
    ProducerTimestamp: 2022-01-28T07:00:37.787Z,
    ServerTimestamp: 2022-01-28T07:00:48.407Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057115779411336479041184133649199',
    FragmentSizeInBytes: 820392,
    ProducerTimestamp: 2022-01-28T07:00:39.643Z,
    ServerTimestamp: 2022-01-28T07:00:49.963Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057120731171493620562686992995215',
    FragmentSizeInBytes: 847071,
    ProducerTimestamp: 2022-01-28T07:00:41.499Z,
    ServerTimestamp: 2022-01-28T07:00:51.466Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057125682931650762084177611210926',
    FragmentSizeInBytes: 763593,
    ProducerTimestamp: 2022-01-28T07:00:43.355Z,
    ServerTimestamp: 2022-01-28T07:00:52.922Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057130634691807903605621447927987',
    FragmentSizeInBytes: 835200,
    ProducerTimestamp: 2022-01-28T07:00:45.211Z,
    ServerTimestamp: 2022-01-28T07:00:54.205Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057135586451965045127000030563099',
    FragmentSizeInBytes: 906677,
    ProducerTimestamp: 2022-01-28T07:00:47.071Z,
    ServerTimestamp: 2022-01-28T07:00:55.244Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057140538212122186648471533739708',
    FragmentSizeInBytes: 685842,
    ProducerTimestamp: 2022-01-28T07:00:48.927Z,
    ServerTimestamp: 2022-01-28T07:00:56.629Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057145489972279328169811940549220',
    FragmentSizeInBytes: 751127,
    ProducerTimestamp: 2022-01-28T07:00:50.783Z,
    ServerTimestamp: 2022-01-28T07:00:57.527Z,
    FragmentLengthInMilliseconds: 1791
  },
  {
    FragmentNumber: '91343852333185057150441732436469691175863905321',
    FragmentSizeInBytes: 733375,
    ProducerTimestamp: 2022-01-28T07:00:52.638Z,
    ServerTimestamp: 2022-01-28T07:00:58.511Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057155393492593611212512597876737',
    FragmentSizeInBytes: 719137,
    ProducerTimestamp: 2022-01-28T07:00:54.494Z,
    ServerTimestamp: 2022-01-28T07:00:59.395Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057160345252750752733848109724600',
    FragmentSizeInBytes: 704671,
    ProducerTimestamp: 2022-01-28T07:00:56.350Z,
    ServerTimestamp: 2022-01-28T07:01:00.274Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057165297012907894255185015258598',
    FragmentSizeInBytes: 726122,
    ProducerTimestamp: 2022-01-28T07:00:58.206Z,
    ServerTimestamp: 2022-01-28T07:01:01.158Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057170248773065035776518554640603',
    FragmentSizeInBytes: 781660,
    ProducerTimestamp: 2022-01-28T07:01:00.062Z,
    ServerTimestamp: 2022-01-28T07:01:02.029Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057175200533222177297851537695855',
    FragmentSizeInBytes: 670833,
    ProducerTimestamp: 2022-01-28T07:01:01.918Z,
    ServerTimestamp: 2022-01-28T07:01:02.899Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057180152293379318819121358297568',
    FragmentSizeInBytes: 756430,
    ProducerTimestamp: 2022-01-28T07:01:03.774Z,
    ServerTimestamp: 2022-01-28T07:01:03.533Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057185104053536460340391192576793',
    FragmentSizeInBytes: 901088,
    ProducerTimestamp: 2022-01-28T07:01:05.630Z,
    ServerTimestamp: 2022-01-28T07:01:04.167Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057190055813693601862044276052305',
    FragmentSizeInBytes: 773312,
    ProducerTimestamp: 2022-01-28T07:01:07.486Z,
    ServerTimestamp: 2022-01-28T07:01:06.229Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057195007573850743383632007202899',
    FragmentSizeInBytes: 768660,
    ProducerTimestamp: 2022-01-28T07:01:09.346Z,
    ServerTimestamp: 2022-01-28T07:01:08.047Z,
    FragmentLengthInMilliseconds: 1791
  },
  {
    FragmentNumber: '91343852333185057199959334007884905218529030717',
    FragmentSizeInBytes: 748856,
    ProducerTimestamp: 2022-01-28T07:01:11.201Z,
    ServerTimestamp: 2022-01-28T07:01:09.861Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057204911094165026426933483564105',
    FragmentSizeInBytes: 763292,
    ProducerTimestamp: 2022-01-28T07:01:13.057Z,
    ServerTimestamp: 2022-01-28T07:01:12.153Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057209862854322167948478491151138',
    FragmentSizeInBytes: 831664,
    ProducerTimestamp: 2022-01-28T07:01:14.913Z,
    ServerTimestamp: 2022-01-28T07:01:13.813Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057214814614479309470058753450625',
    FragmentSizeInBytes: 751255,
    ProducerTimestamp: 2022-01-28T07:01:16.769Z,
    ServerTimestamp: 2022-01-28T07:01:15.603Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057219766374636450991675003849379',
    FragmentSizeInBytes: 769545,
    ProducerTimestamp: 2022-01-28T07:01:18.625Z,
    ServerTimestamp: 2022-01-28T07:01:17.528Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057224718134793592513326318973487',
    FragmentSizeInBytes: 757835,
    ProducerTimestamp: 2022-01-28T07:01:20.481Z,
    ServerTimestamp: 2022-01-28T07:01:19.583Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057229669894950734034908059013802',
    FragmentSizeInBytes: 790785,
    ProducerTimestamp: 2022-01-28T07:01:22.337Z,
    ServerTimestamp: 2022-01-28T07:01:21.380Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057234621655107875556490501268794',
    FragmentSizeInBytes: 800209,
    ProducerTimestamp: 2022-01-28T07:01:24.193Z,
    ServerTimestamp: 2022-01-28T07:01:23.178Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057239573415265017078113082715299',
    FragmentSizeInBytes: 784770,
    ProducerTimestamp: 2022-01-28T07:01:26.049Z,
    ServerTimestamp: 2022-01-28T07:01:25.127Z,
    FragmentLengthInMilliseconds: 1795
  },
  {
    FragmentNumber: '91343852333185057244525175422158599662409003435',
    FragmentSizeInBytes: 733595,
    ProducerTimestamp: 2022-01-28T07:01:27.904Z,
    ServerTimestamp: 2022-01-28T07:01:26.802Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057249476935579300121271711940811',
    FragmentSizeInBytes: 863091,
    ProducerTimestamp: 2022-01-28T07:01:29.760Z,
    ServerTimestamp: 2022-01-28T07:01:28.701Z,
    FragmentLengthInMilliseconds: 1796
  },
  {
    FragmentNumber: '91343852333185057254428695736441642978804126889',
    FragmentSizeInBytes: 794767,
    ProducerTimestamp: 2022-01-28T07:01:31.620Z,
    ServerTimestamp: 2022-01-28T07:01:30.964Z,
    FragmentLengthInMilliseconds: 1792
  },
  {
    FragmentNumber: '91343852333185057259380455893583164563849312914',
    FragmentSizeInBytes: 815843,
    ProducerTimestamp: 2022-01-28T07:01:33.476Z,
    ServerTimestamp: 2022-01-28T07:01:32.772Z,
    FragmentLengthInMilliseconds: 1792
  }
]

the total duration of all fragments: 57421 MS

The M3U file:


#EXTM3U
#EXT-X-VERSION:7
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="getMP4InitFragment.mp4?SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1"
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:35.931Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057105875891022195998207386831087&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:37.787Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057110827651179337519666762451998&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:39.643Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057115779411336479041184133649199&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:41.499Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057120731171493620562686992995215&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:43.355Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057125682931650762084177611210926&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:45.211Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057130634691807903605621447927987&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:47.071Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057135586451965045127000030563099&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:48.927Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057140538212122186648471533739708&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:50.783Z
#EXTINF:1.852,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057145489972279328169811940549220&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:52.638Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057150441732436469691175863905321&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:54.494Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057155393492593611212512597876737&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:56.350Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057160345252750752733848109724600&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:00:58.206Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057165297012907894255185015258598&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:00.062Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057170248773065035776518554640603&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:01.918Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057175200533222177297851537695855&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:03.774Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057180152293379318819121358297568&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:05.630Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057185104053536460340391192576793&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:07.486Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057190055813693601862044276052305&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:09.346Z
#EXTINF:1.852,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057195007573850743383632007202899&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:11.201Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057199959334007884905218529030717&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:13.057Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057204911094165026426933483564105&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:14.913Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057209862854322167948478491151138&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:16.769Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057214814614479309470058753450625&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:18.625Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057219766374636450991675003849379&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:20.481Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057224718134793592513326318973487&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:22.337Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057229669894950734034908059013802&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:24.193Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057234621655107875556490501268794&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:26.049Z
#EXTINF:1.856,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057239573415265017078113082715299&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:27.904Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057244525175422158599662409003435&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:29.760Z
#EXTINF:1.857,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057249476935579300121271711940811&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:31.620Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057254428695736441642978804126889&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-PROGRAM-DATE-TIME:2022-01-28T07:01:33.476Z
#EXTINF:1.853,
getMP4MediaFragment.mp4?FragmentNumber=91343852333185057259380455893583164563849312914&SessionToken=CiBFQ5hwk0gJ4y0yZel0pfEM048uaoiqfynqb3Or3PnbBRIQCNXzXfY3UUFHJCBRHnqwUhoZHHw48q4PWtF3iPhcl1vK0ilc18UrzzrePiIgSBupoTd0SDcBQUc4wGmBkVGaMshh0QRhSG3Y8Ku8I2Q~&TrackNumber=1
#EXT-X-ENDLIST

The total duration of all fragments: 5900 MS

As you can see the return fragments' numbers are identical but their length is different.
My question is how can it be?

Which other why do I have to get the duration of the fragments for some time range without retrieving the entire stream for that time range?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.