amazon-kinesis-video-streams-parser-library icon indicating copy to clipboard operation
amazon-kinesis-video-streams-parser-library copied to clipboard

[QUESTION] Properly restart the pipeline when token is expired

Open FlorianRuen opened this issue 3 years ago • 21 comments

Hello everyone,

I'm using the KVS producer to send video feed from RTSP camera to KVS (using Python on Raspberry PI), this works perfectly. But on the other side, I'm using the parser library to extract the images and do some tasks on it.

On your documentation it writed that the token for GetMedia expire every 50 minutes, so if we need to extract images 24/7, we need to refresh the token every 45 minutes (cf one of my previous issue on this subject : https://github.com/aws/amazon-kinesis-video-streams-parser-library/issues/108)

So I try to apply something to automatic restart the process every 45 minutes (my code is in Kotlin), which is :

val getMediaWorker = GetMediaWorker.create(
    ........
)

if (getMediaWorker != null) {
     try {
         val future = executorService.submit(getMediaWorker)
         future.get(45, TimeUnit.MINUTES)
     } catch (te: TimeoutException) {
        logger.error("Will restart to avoid auto-stop due to 50 minutes of KVS Session")
        executorService.shutdownNow()
        kvsSessionExpiredOrNeedToRestartConsumer = true
    }
}

This works, my session restart every 45 minutes, and I didn't got a message due tu ClientLimitException or something else. But this solution, cause a NullPointerException after some restarts, and I didn't find why (I try to add a lot of catch to find where is the NullPointerException, but none of my blocks are fired)

The error is the following (hosted images on the error) : Capture d’écran de 2021-04-13 07-52-31

Maybe you have another way to avoid the issue with the KVS max session duration ? Another thing that my future way to do this ?

Don't hesitate if you need more informations on my use case,

Kind regards, Florian

FlorianRuen avatar Apr 13 '21 06:04 FlorianRuen