我正在尝试使用AWS Batch C ++ API。这是我写的一个非常基本的演示程序,只是列出了可用的作业定义:
#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;
}
当我运行程序时,我收到此错误输出:
Could not get JobDefinition list
error: - Unable to connect to endpoint
Response code: 0
请注意,错误消息(descjob_outcome.GetError()。GetMessage())是“无法连接到端点”,但异常名称(descjob_outcome.GetError()。GetExceptionName())实际上是一个空字符串,介于“错误: “和” - “在我的格式化输出中。此外,响应代码为0,这不是HttpResponse.h中列出的代码。
我不认为问题出在我的AWS配置中,因为我从Github下载了aws-doc-sdk-examples repo,我可以编译并运行那里的C ++示例(例如,s3中的list_buckets程序)夹)。不幸的是,aws-doc-sdk-examples不包含任何Batch示例代码,这是我最感兴趣使用的API的一部分。
我还想要注意,我能够运行一个使用AWS Batch API的简单python程序(通过boto3模块),所以我不认为这个问题特别适用于我的AWS配置。
任何人都可以在我的演示代码中看到一个问题,可以解释“无法连接到端点”错误,或者可能会建议一些资源可以帮助我更清楚地了解它无法连接的原因?我不太明白为什么它没有给我一个有效的异常名称或响应代码,例如。
Aws Batch仅支持HTTPS端点。