Getting a 400 subscription maxResult while trying to obtain Mediaconvert endpoint in AWS

89 views Asked by At

I'm using AWS Java SDK v.2 with the Mediaconvert service successfully for months. I'm working on a new application, and doing a lot of stop/start of my application during development. My service obtains an endpoint upon startup, which has been working great for months. Now, I'm getting the following error trying to form a connection, not even submitting a job, just getting the client set up:

Unable to fetch AWS Mediaconvert API Endpoint for trancoding: api.error.400.subscription.maxResult (Service: MediaConvert, Status Code: 400, Request ID:...

My java code for getting getting this endpoint is this:

    Region region = Region.of(awsRegion);
    ProfileCredentialsProvider credentialsProvider = ProfileCredentialsProvider.create();
    
    mediaConvertClient = MediaConvertClient.builder()
            .credentialsProvider(credentialsProvider)
            .region(region)
            .build();

    logger.info("************ Obtaining AWS Mediconvert API endpoint...");

    if (awsMediaconvertEndpoint == null || awsMediaconvertEndpoint.contentEquals("")) {

        try {
            DescribeEndpointsResponse res = mediaConvertClient
                    .describeEndpoints(DescribeEndpointsRequest.builder().maxResults(20).build());

            if (res.endpoints().size() <= 0) {
                logger.error("Cannot find MediaConvert service endpoint URL!");
                System.exit(1);
            }

            awsMediaconvertEndpoint = res.endpoints().get(0).url();

        } catch (Exception e) {
            logger.error("Unable to fetch AWS Mediaconvert API Endpoint for trancoding: " + e.getMessage());
            System.exit(1);
        }

    }

    mediaConvertClient = MediaConvertClient.builder()
            .region(region)
            .endpointOverride(URI.create(awsMediaconvertEndpoint))
            .build();
    
    logger.info("************ New AWS Mediaconvert endpoint is: " + awsMediaconvertEndpoint);

This was working most of the day today, and just started throwing this 400 error. Is there something I should be doing to "shut down" the endpoint connection or some how "clean it up" when my application is shutting down?

2

There are 2 answers

0
VSE On BEST ANSWER

It is likely that the 400 error is due to the API transactions-per-second being hit and the call being throttled. The request rate limit for the Describe Endpoints call is 0.01667 calls per second (once per minute).

The endpoint URL is specific to your AWS Region and won’t change. Request this endpoint once, and then hardcode it (as you did in your second post) or cache it. You found the best answer yourself.

FYI The documentation the various TPS limits can be found at : https://docs.aws.amazon.com/general/latest/gr/mediaconvert.html

0
user2989397 On

I went to using using the endpoint obtained from the AWS Mediaconvert web management tool and assign it directly, without trying to fetch it.

private final String mediaConvertAPIEndpoint = "https://<endpointcode>.mediaconvert.<region>.amazonaws.com";
mediaConvertClient = MediaConvertClient.builder()
                    .region(region)
                .endpointOverride(URI.create(mediaConvertAPIEndpoint))
                .build();

I still don't have a reason why using the "describeEndpoints" method was failing.