awslabs / amazon-kinesis-video-streams-producer-c

https://awslabs.github.io/amazon-kinesis-video-streams-producer-c/group__PublicMemberFunctions.html
Apache License 2.0
54 stars 72 forks source link

[QUESTION] Iot credential expiration time 3600 seconds #196

Closed henryChmn closed 3 years ago

henryChmn commented 3 years ago

Just confuse sometime we can uploading stream over 3600 seconds.

image

021-02-20 04:55:31 VERBOSE convertTimestampToEpoch(): Expiration timestamp conversion into tm structure 121-1-20T5:55:30 2021-02-20 04:55:31 DEBUG convertTimestampToEpoch(): Difference between current time and iot expiration is 3599 2021-02-20 04:55:31 DEBUG parseIotResponse(): Iot credential expiration time 1613800530

2021-02-18 03:24:07 DEBUG logStreamMetric(): Kinesis Video client and stream metrics: 2021-02-18 03:24:07 DEBUG logStreamMetric(): Overall storage byte size: 5242880 2021-02-18 03:24:07 DEBUG logStreamMetric(): Available storage byte size: 4842984 2021-02-18 03:24:07 DEBUG logStreamMetric(): Allocated storage byte size: 399896 2021-02-18 03:24:07 DEBUG logStreamMetric(): Total view allocation byte size: 691280 2021-02-18 03:24:07 DEBUG logStreamMetric(): Total streams frame rate (fps): 202 2021-02-18 03:24:07 DEBUG logStreamMetric(): Total streams transfer rate (bps): 1411008 (1377 Kbps) 2021-02-18 03:24:07 DEBUG logStreamMetric(): Current view duration (ms): 668 2021-02-18 03:24:07 DEBUG logStreamMetric(): Overall view duration (ms): 1935 2021-02-18 03:24:07 DEBUG logStreamMetric(): Current view byte size: 67432 2021-02-18 03:24:07 DEBUG logStreamMetric(): Overall view byte size: 321168 2021-02-18 03:24:07 DEBUG logStreamMetric(): Current frame rate (fps): 202.938463 2021-02-18 03:24:07 DEBUG logStreamMetric(): Current transfer rate (bps): 1411008 (1377 Kbps) 2021-02-18 03:24:07 DEBUG logStreamMetric(): Stream uptime in (ms): 6620783 2021-02-18 03:24:07 DEBUG logStreamMetric(): Total transferred bytes: 1047599475 2021-02-18 03:24:07 DEBUG logStreamMetric(): Total number of streaming sessions: 6 2021-02-18 03:24:07 DEBUG logStreamMetric(): Total number of active streaming sessions: 6 2021-02-18 03:24:07 DEBUG logStreamMetric(): Average streaming sessions duration: 2174977488 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of Buffered ACKs: 6608 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of Received ACKs: 6606 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of Persisted ACKs: 6606 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of Error ACKs: 1 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of dropped frames: 0 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of skipped frames: 30 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of storage pressure events: 0 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of latency pressure events: 0 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of buffer pressure events: 0 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of stream staleness events: 0 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of latency pressure events: 0 2021-02-18 03:24:07 DEBUG logStreamMetric(): Number of Put Frame errors: 0 2021-02-18 03:24:07 DEBUG logStreamMetric(): Average Control Plane API latency (ms): 129 2021-02-18 03:24:07 DEBUG logStreamMetric(): Average Data Plane API latency (ms): 1

MushMal commented 3 years ago

KVS itself can stream indefinitely. It will simply update the credentials whenever it's needing it. Check your logs for the token rotation. Each KVS streaming session is up-to 40 minutes and the credentials will be rotated whenever a new session is established and whenever the credentials are about to expire.

henryChmn commented 3 years ago

I check with log, parseIotResponse(): Iot credential expiration time 1613081628 (Thu Feb 11 2021 22:13:48 UTC Time) but still have problem next second.

log: 2021-02-11 21:13:48 DEBUG stepStateMachine(): State Machine - Current state: 0x0000000000000040, Next state: 0x0000000000000080 2021-02-11 21:13:48 DEBUG stepStateMachine(): State Machine - Current state: 0x0000000000000040, Next state: 0x0000000000000002 2021-02-11 21:13:48 DEBUG convertTimestampToEpoch(): Difference between current time and iot expiration is 3600 2021-02-11 21:13:48 DEBUG parseIotResponse(): Iot credential expiration time 1613081628 2021-02-11 21:13:48 DEBUG stepStateMachine(): State Machine - Current state: 0x0000000000000002, Next state: 0x0000000000000040 2021-02-11 21:13:48 INFO putStreamResultEvent(): Put stream result event. New upload handle 11 2021-02-11 21:13:48 DEBUG stepStateMachine(): State Machine - Current state: 0x0000000000000080, Next state: 0x0000000000000100 2021-02-11 21:13:48 DEBUG logStreamMetric(): Kinesis Video client and stream metrics: 2021-02-11 21:13:48 DEBUG logStreamMetric(): Overall storage byte size: 5242880 2021-02-11 21:13:48 DEBUG logStreamMetric(): Available storage byte size: 5180296 2021-02-11 21:13:48 DEBUG logStreamMetric(): Allocated storage byte size: 62584 2021-02-11 21:13:48 DEBUG logStreamMetric(): Total view allocation byte size: 691280 2021-02-11 21:13:48 DEBUG logStreamMetric(): Total streams frame rate (fps): 120 2021-02-11 21:13:48 DEBUG logStreamMetric(): Total streams transfer rate (bps): 16777216 (16384 Kbps) 2021-02-11 21:13:48 DEBUG logStreamMetric(): Current view duration (ms): 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Overall view duration (ms): 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Current view byte size: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Overall view byte size: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Current frame rate (fps): 120.000000 2021-02-11 21:13:48 DEBUG logStreamMetric(): Current transfer rate (bps): 16777216 (16384 Kbps) 2021-02-11 21:13:48 DEBUG logStreamMetric(): Stream uptime in (ms): 3660020 2021-02-11 21:13:48 DEBUG logStreamMetric(): Total transferred bytes: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Total number of streaming sessions: 1 2021-02-11 21:13:48 DEBUG logStreamMetric(): Total number of active streaming sessions: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Average streaming sessions duration: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of Buffered ACKs: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of Received ACKs: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of Persisted ACKs: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of Error ACKs: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of dropped frames: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of skipped frames: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of storage pressure events: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of latency pressure events: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of buffer pressure events: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of stream staleness events: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of latency pressure events: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Number of Put Frame errors: 0 2021-02-11 21:13:48 DEBUG logStreamMetric(): Average Control Plane API latency (ms): 60 2021-02-11 21:13:48 DEBUG logStreamMetric(): Average Data Plane API latency (ms): 42 2021-02-11 21:13:49 DEBUG logStreamMetric(): Kinesis Video client and stream metrics: 2021-02-11 21:13:49 DEBUG logStreamMetric(): Overall storage byte size: 5242880 2021-02-11 21:13:49 DEBUG logStreamMetric(): Available storage byte size: 5031368 2021-02-11 21:13:49 DEBUG logStreamMetric(): Allocated storage byte size: 211512 2021-02-11 21:13:49 DEBUG logStreamMetric(): Total view allocation byte size: 691280 2021-02-11 21:13:49 DEBUG logStreamMetric(): Total streams frame rate (fps): 329 2021-02-11 21:13:49 DEBUG logStreamMetric(): Total streams transfer rate (bps): 16777216 (16384 Kbps) 2021-02-11 21:13:49 DEBUG logStreamMetric(): Current view duration (ms): 934 2021-02-11 21:13:49 DEBUG logStreamMetric(): Overall view duration (ms): 934 2021-02-11 21:13:49 DEBUG logStreamMetric(): Current view byte size: 148137 2021-02-11 21:13:49 DEBUG logStreamMetric(): Overall view byte size: 148137 2021-02-11 21:13:49 DEBUG logStreamMetric(): Current frame rate (fps): 329.018331 2021-02-11 21:13:49 DEBUG logStreamMetric(): Current transfer rate (bps): 16777216 (16384 Kbps) 2021-02-11 21:13:49 DEBUG logStreamMetric(): Stream uptime in (ms): 3660246 2021-02-11 21:13:49 DEBUG logStreamMetric(): Total transferred bytes: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Total number of streaming sessions: 1 2021-02-11 21:13:49 DEBUG logStreamMetric(): Total number of active streaming sessions: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Average streaming sessions duration: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of Buffered ACKs: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of Received ACKs: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of Persisted ACKs: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of Error ACKs: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of dropped frames: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of skipped frames: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of storage pressure events: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of latency pressure events: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of buffer pressure events: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of stream staleness events: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of latency pressure events: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Number of Put Frame errors: 0 2021-02-11 21:13:49 DEBUG logStreamMetric(): Average Control Plane API latency (ms): 60 2021-02-11 21:13:49 DEBUG logStreamMetric(): Average Data Plane API latency (ms): 42 2021-02-11 21:13:49 INFO writeHeaderCallback(): RequestId: f3b644b6-b3c9-39f8-ab29-e4fbfbfe345e 2021-02-11 21:13:49 DEBUG postWriteCallback(): Curl post body write function for stream with handle: prod-b0c5ca3ad1b4-136c5a4d52fa11eaad8206fe464651f4 and upload handle: 11 returned: {"message":"The security token included in the request is expired"} 2021-02-11 21:13:49 ERROR kinesisVideoStreamParseFragmentAck(): operation returned status code: 0x52000051 2021-02-11 21:13:49 WARN postWriteCallback(): Failed to submit ACK: {"message":"The security token included in the request is expired"} with status code: 0x52000051 2021-02-11 21:13:49 WARN curlCompleteSync(): HTTP Error 403 : Response: (null) Request URL: https://s-8451b5cd.kinesisvideo.us-west-2.amazonaws.com/putMedia Request Headers: Authorization: AWS4-HMAC-SHA256 Credential=ASIAQ4GMKQ5OZWIAGTR3/20210211/us-west-2/kinesisvideo/aws4_request, SignedHeaders=connection;host;transfer-encoding;user-agent;x-amz-date;x-amzn-fragment-acknowledgment-required;x-amzn-fragment-timecode-type;x-amzn-producer-start-timestamp;x-amzn-stream-name, Signature=c57676ca0c215d5cc 2021-02-11 21:13:49 DEBUG putStreamCurlHandler(): Network thread for Kinesis Video stream: prod-b0c5ca3ad1b4-136c5a4d52fa11eaad8206fe464651f4 with upload handle: 11 exited. http status: 403 2021-02-11 21:13:49 WARN putStreamCurlHandler(): Stream with streamHandle 823024 uploadHandle 11 has exited without triggering end-of-stream. Service call result: 403 2021-02-11 21:13:49 INFO kinesisVideoStreamTerminated(): Stream 0xc8ef0 terminated upload handle 11 with service call result 403.

MushMal commented 3 years ago

This is an unrelated question to your original post. Try to ensure the clock on the device is in-sync. Most implementations use some sort of an NTP service to adjust and keep the clock in-sync

henryChmn commented 3 years ago

Yes, we did it already to keep the clock in-sync

MushMal commented 3 years ago

I am drawing a blank. Try to run some debugging, ensure your gettime returns the same clock value as the service.

disa6302 commented 3 years ago

Closing due to inactivity. Feel free to reopen the issue when you have more details.