SDKOptions timeout configuration not working in dns timeout
joker-gege opened this issue · 2 comments
Describe the bug
When I configured an incorrect DNS(centos7.6 wrong configuration of etc/resolv. conf), I found that Aws::SDKOptions timeout configuration not work。Timeout set 500ms,but when i use HeadObject function will cost 5-7s return
Expected Behavior
The expected behavior is that: the Headobject call can return as timeout set 500ms
Current Behavior
now HeadObject function would take approximately 6-7s
Reproduction Steps
code like this,please use yourself ak,sk,bucketname,endpoint
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/HeadObjectRequest.h>
#include <iostream>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/DefaultRetryStrategy.h>
using namespace Aws;
using namespace Aws::Auth;
int main(int argc, char **argv) {
Aws::SDKOptions options;
Aws::InitAPI(options); // Should only be called once.
int result = 0;
{
const Aws::String ak = "xxxxxxxxxxxx";
const Aws::String sk = "xxxxxxxxxxxx";
const Aws::String bn = "xxxxxxxxxxxx";
const Aws::String ep = "xxxxxxxxxxxx";
const Aws::String objKey = "test/test/test";
Aws::Client::ClientConfiguration ossOption;
ossOption.connectTimeoutMs=500;
ossOption.httpRequestTimeoutMs=500;
ossOption.requestTimeoutMs=500;
ossOption.endpointOverride = ep;
ossOption.scheme = Aws::Http::Scheme::HTTP;
ossOption.verifySSL = false;
ossOption.region = Aws::String("bj");
std::shared_ptr<Aws::Client::RetryStrategy> retry(new Aws::Client::DefaultRetryStrategy(0, 0));
ossOption.retryStrategy= retry;
Aws::Auth::AWSCredentials cred(ak, sk);
auto s3Client_ = new Aws::S3::S3Client(cred, ossOption, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Always, true);
Aws::S3::Model::HeadObjectRequest request;
request.SetBucket(bn);
request.SetKey(objKey);
Aws::S3::Model::HeadObjectOutcome get_object_outcome = s3Client_->HeadObject(request);
// Aws::Map<Aws::String, Aws::String> meta;
if (get_object_outcome.IsSuccess()) {
std::cout << "success" << std::endl;
} else {
std::cout << "failuer: " << get_object_outcome.GetError() << std::endl;
}
}
Aws::ShutdownAPI(options);
return result;
}
Possible Solution
No response
Additional Information/Context
No response
AWS CPP SDK version used
1.11.34
Compiler and Version used
gcc version 8.3.1
Operating System and version
CentOS 7.6
i found this question possible caused by libcurl, the code in CurlHandleContainer.cpp
void CurlHandleContainer::SetDefaultOptionsOnHandle(CURL* handle)
{
//for timeouts to work in a multi-threaded context,
//always turn signals off. This also forces dns queries to
//not be included in the timeout calculations.
curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt(handle, CURLOPT_TIMEOUT_MS, m_httpRequestTimeout);
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT_MS, m_connectTimeout);
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_LIMIT, m_lowSpeedLimit);
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_TIME, m_lowSpeedTime < 1000 ? (m_lowSpeedTime == 0 ? 0 : 1) : m_lowSpeedTime / 1000);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPALIVE, m_enableTcpKeepAlive ? 1L : 0L);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPINTVL, m_tcpKeepAliveIntervalMs / 1000);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPIDLE, m_tcpKeepAliveIntervalMs / 1000);
curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, ConvertHttpVersion(m_version));
curl_easy_setopt(handle, CURLOPT_MAXCONNECTS, m_maxPoolSize);
}
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.