2016-07-28 254 views
2

在使用AWS C++ SDK时,遇到了尝试执行PutObjectRequest的问题,当上载超过400KB时,它会“无法连接到端点”。AWS C++ S3 SDK PutObjectRequest无法连接到端点

Aws::Client::ClientConfiguration clientConfig; 
clientConfig.scheme = Aws::Http::Scheme::HTTPS; 
clientConfig.region = Aws::Region::US_EAST_1; 

Aws::S3::S3Client s3Client(clientConfig); 

Aws::S3::Model::PutObjectRequest putObjectRequest; 
putObjectRequest.SetBucket("mybucket"); 
putObjectRequest.SetKey("mykey"); 

typedef boost::iostreams::basic_array_source<char> Device; 
boost::iostreams::stream_buffer<Device> stmbuf(compressedData, dataSize); 
std::iostream *stm = new std::iostream(&stmbuf); 

putObjectRequest.SetBody(std::shared_ptr<Aws::IOStream>(stm)); 
putObjectRequest.SetContentLength(dataSize); 

Aws::S3::Model::PutObjectOutcome outcome = s3Client.PutObject(putObjectRequest); 

只要我的数据小于400KB〜其上传到S3上的一个文件,但除此之外,它是无法连接到端点。我应该可以在一个PutObjectRequest中上传5GB。

有什么想法?

编辑:

回应@ JonathanHenson的评论中,AWS日志显示此超时错误重复:

[DEBUG] 2016-08-04 13:42:03 AWSClient [0x700000081000] Request Successfully signed 
[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] Making request to https://s3.amazonaws.com/mybucket/myfile 
[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] Including headers: 
[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] content-length: 3151261 
[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] content-type: binary/octet-stream 
[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] host: s3.amazonaws.com 
[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] user-agent: aws-sdk-cpp/0.13.9 Darwin/15.6.0 x86_64 
[DEBUG] 2016-08-04 13:42:03 CurlHandleContainer [0x700000081000] Attempting to acquire curl connection. 
[DEBUG] 2016-08-04 13:42:03 CurlHandleContainer [0x700000081000] Returning connection handle 0x10b09cc00 
[DEBUG] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] Obtained connection handle 0x10b09cc00 
[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] HTTP/1.1 100 Continue 

[TRACE] 2016-08-04 13:42:03 CurlHttpClient [0x700000081000] 

[ERROR] 2016-08-04 13:42:06 CurlHttpClient [0x700000081000] Curl returned error code 28 
[DEBUG] 2016-08-04 13:42:06 CurlHandleContainer [0x700000081000] Releasing curl handle 0x10b09cc00 
[DEBUG] 2016-08-04 13:42:06 CurlHandleContainer [0x700000081000] Notifying waiting threads. 
[DEBUG] 2016-08-04 13:42:06 AWSClient [0x700000081000] Request returned error. Attempting to generate appropriate error codes from response 
[WARN] 2016-08-04 13:42:06 AWSClient [0x700000081000] Request failed, now waiting 12800 ms before attempting again. 
[DEBUG] 2016-08-04 13:42:19 InstanceProfileCredentialsProvider [0x700000081000] Checking if latest credential pull has expired. 
+0

你能每次给我发送一个日志文件吗?我很乐意看到这一点。 –

+0

感谢评论@JonathanHenson。我编辑了问题以显示日志文件中的错误。我可以通过电子邮件与您联系吗? –

+0

我看到你在苹果设备上这样做。这是否通过WiFi?如果是的话,你可以通过以太网尝试吗? –

回答

1

最终是什么修复了这个对我来说是设置请求超时。请求超时时间需要足够长,以便完成整个传输。如果您在缓慢的Internet连接上传输大文件,请确保请求超时时间足够长以允许传输这些文件。

Aws::Client::ClientConfiguration clientConfig; 
clientConfig.scheme = Aws::Http::Scheme::HTTPS; 
clientConfig.region = Aws::Region::US_EAST_1; 
clientConfig.connectTimeoutMs = 30000; 
clientConfig.requestTimoutMs = 600000; 
+0

这是一个已知的curl问题,因为我错误地认为超时选项是正常的套接字读取超时,事实并非如此。我正在修复我们的libcurl代码,使其表现得像一个正常的读取超时,这不应该成为一个问题了。 –

0

调整您的配置文件,以below.And看到它的工作。

Aws::Client::ClientConfiguration clientConfig; 
clientConfig.scheme = Aws::Http::Scheme::HTTPS; 
clientConfig.region = Aws::Region::US_EAST_1; 
clientConfig.connectTimeoutMs = 30000; 

Aws::S3::S3Client s3Client(clientConfig); 

Aws::S3::Model::PutObjectRequest putObjectRequest; 
putObjectRequest.SetBucket("mybucket"); 
putObjectRequest.SetKey("mykey"); 

typedef boost::iostreams::basic_array_source<char> Device; 
boost::iostreams::stream_buffer<Device> stmbuf(compressedData, dataSize); 
std::iostream *stm = new std::iostream(&stmbuf); 

putObjectRequest.SetBody(std::shared_ptr<Aws::IOStream>(stm)); 
putObjectRequest.SetContentLength(dataSize); 

Aws::S3::Model::PutObjectOutcome outcome = s3Client.PutObject(putObjectRequest); 
+0

不幸的是,它仍然无法连接到端点错误,即使设置超时 'clientConfig.connectTimeoutMs = 30000;' –

+0

无论如何,连接超时是错误的设置,如果它在发送期间超时,它实际上是接收超时。 –