2016-07-28 140 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

無論如何,連接超時是錯誤的設置,如果它在發送期間超時,它實際上是接收超時。 –