1

I am trying to get the AWS Batch C++ API working. Here is a very basic demo program I wrote to simply list the available job definitions:

#include <iostream>
#include <aws/core/Aws.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/Outcome.h>
#include <aws/batch/BatchClient.h>
#include <aws/batch/model/DescribeJobDefinitionsRequest.h>

using namespace Aws::Batch::Model;

int main()
{
    //Initialize AWS Batch
    Aws::SDKOptions options;
    Aws::InitAPI(options);
    {
        Aws::Client::ClientConfiguration aws_config;
        aws_config.scheme = Aws::Http::Scheme::HTTP;
        aws_config.connectTimeoutMs = 30000;
        aws_config.requestTimeoutMs = 30000;
        aws_config.verifySSL = false;

        Aws::Batch::BatchClient batch_client(aws_config);

        //Get the list of job definitions
        DescribeJobDefinitionsRequest descjob_request;
        auto descjob_outcome = batch_client.DescribeJobDefinitions(descjob_request);
        if (descjob_outcome.IsSuccess() == true)
        {
            auto job_list = descjob_outcome.GetResult().GetJobDefinitions();
            Aws::Vector<JobDefinition>::iterator it;
            for (it=job_list.begin(); it != job_list.end(); ++it)
            {
                std::cout << "    " 
                          << it->GetJobDefinitionName() 
                          << ":" 
                          << it->GetRevision() 
                          << "  (" 
                          << it->GetStatus() 
                          << ")" 
                          << std::endl;
            }
        }
        else
        {
            std::cout << "Could not get JobDefinition list" << std::endl;
            std::cout << "error: "
                      << descjob_outcome.GetError().GetExceptionName() << " - "
                      << descjob_outcome.GetError().GetMessage() << std::endl;
            std::cout << "Response code: "
                      << int(descjob_outcome.GetError().GetResponseCode()) << std::endl;
        }
    }
    Aws::ShutdownAPI(options);

    return 0;
}

When I run the program, I get this error output:

Could not get JobDefinition list
error:  - Unable to connect to endpoint
Response code: 0

Note that the error message (descjob_outcome.GetError().GetMessage()) is "Unable to connect to endpoint", but the Exception name (descjob_outcome.GetError().GetExceptionName()) is actually an empty string, between "error: " and "-" in my formatted output. Also, the Response code is 0, which is not among the codes listed in HttpResponse.h.

I don't think the problem is in my AWS config, because I downloaded the aws-doc-sdk-examples repo from Github, and I can compile and run the C++ examples there just fine (for example, the list_buckets program in the s3 folder). Unfortunately, aws-doc-sdk-examples does not include any Batch example code, which is the part of the API that I am most interested in using.

I also want to note that I am able to run a simple python program that uses the AWS Batch API (through the boto3 module), so again I don't think this problem is particular to my AWS configuration.

Can anyone see a problem in my demo code that could explain the "unable to connect to endpoint" error, or perhaps suggest some resources that can help me get more clarity on why it is failing to connect? I don't really understand why it's not giving me a valid exception name or response code, for example.

1 Answers1

1

Aws Batch only supports HTTPS endpoint.

user2706071
  • 196
  • 9
  • 1
    https://docs.aws.amazon.com/general/latest/gr/rande.html#batch_region You can see from here that there is no HTTP endpoint. – user2706071 Mar 06 '18 at 19:38