aws / amazon-kinesis-video-streams-parser-library

Amazon Kinesis Video Streams parser library is for developers to include in their applications that makes it easy to work with the output of video streams such as retrieving frame-level objects, metadata for fragments, and more.
Apache License 2.0
103 stars 52 forks source link

PutMedia on newly created stream gives Service: AmazonKinesisVideoMedia; Status Code: 403; Error Code: null #106

Closed samjoshi26 closed 4 years ago

samjoshi26 commented 4 years ago

I create a stream in us-east-1 region using aws access key and write to it. I keep getting the following error

onFailure: * null (Service: AmazonKinesisVideoMedia; Status Code: 403; Error Code: null; Request ID: f9b10ee1-fa12-dd8c-aecd-b1315f760526)

This happens with my java code. I use the same access keys in PutMedia.java demo class and it is able to write to the stream without any issue. Just to double check, I created another set of keys today and tried but am not able to get rid of the issue. Any help would be appreciated.

lherman-cs commented 4 years ago

@samjoshi26 did you use the endpoint from getDataEndpoint? You need to something like,

       final String dataEndpoint = frontendClient.getDataEndpoint(
                new GetDataEndpointRequest()
                        .withStreamName(STREAM_NAME)
                        .withAPIName("PUT_MEDIA")).getDataEndpoint();

            final URI uri = URI.create(dataEndpoint + PUT_MEDIA_API);
            final AmazonKinesisVideoPutMedia dataClient = AmazonKinesisVideoPutMediaClient.builder()
                    .withRegion(DEFAULT_REGION)
                    .withEndpoint(URI.create(dataEndpoint)) // <-- notice here the endpoint is from getDataEndpoint
                    .withCredentials(AuthHelper.getSystemPropertiesCredentialsProvider())
                    .withConnectionTimeoutInMillis(CONNECTION_TIMEOUT_IN_MILLIS)
                    .build();
samjoshi26 commented 4 years ago

@lherman-cs . Thank you for your reply. Yes I have done it exactly as you have pointed out. I want to know what is the purpose of this line final URI uri = URI.create(dataEndpoint + PUT_MEDIA_API); as uri object is not being used anywhere in the demo code as well

String endPoint = client.getDataEndpoint(newGetDataEndpointRequest().withStreamName(streamName).withAPIName(APIName.PUT_MEDIA)) .getDataEndpoint();

Later to this String endPoint , I append "/putMedia" endPoint = endPoint + "/putMedia";

Then I use it as follows AmazonKinesisVideoPutMediaClient.builder().withRegion(region).withEndpoint(URI.create(endPoint)) .withCredentials(new AWSStaticCredentialsProvider(credentials)).build(); I have not included my credentials details. Please let me know if I am doing anything wrong.

Thank you again!

samjoshi26 commented 4 years ago

I have removed the line endPoint = endPoint + "/putMedia"; and everything works now! Thank you for your reply

lherman-cs commented 4 years ago

@samjoshi26 hey, sorry, you're right, final URI uri = URI.create(dataEndpoint + PUT_MEDIA_API); is not needed.

lherman-cs commented 4 years ago

@samjoshi26 In this case, would you mind to close the issue?