0
最近,我已經開始使用AWS C++ SDK並取得了一些成功。那些基於HTTPS GET的調用工作正常。對於IoT REST API,我可以創建Things和ListThings。使用AWS C++ SDK時,調用UpdateThing返回504網關超時
但是,當我調用UpdateThing請求時,調用會掛起,並且在超時時出現AWS 504網關超時錯誤。
我已經嘗試了一些東西,但無濟於事。似乎很少有公佈的例子可以幫助我解決這個問題。
的AWS調試日誌輸出是在這裏:
[DEBUG] 2017-01-03 22:08:42 AWSClient [0x7fff755d1000] Request Successfully signed
[DEBUG] 2017-01-03 22:08:42 CurlHandleContainer [0x7fff755d1000] Attempting to acquire curl connection.
[DEBUG] 2017-01-03 22:08:42 CurlHandleContainer [0x7fff755d1000] No current connections available in pool. Attempting to create new connections.
[DEBUG] 2017-01-03 22:08:42 CurlHandleContainer [0x7fff755d1000] attempting to grow pool size by 2
[INFO] 2017-01-03 22:08:42 CurlHandleContainer [0x7fff755d1000] Pool successfully grown by 2
[INFO] 2017-01-03 22:08:42 CurlHandleContainer [0x7fff755d1000] Connection has been released. Continuing.
[DEBUG] 2017-01-03 22:08:42 CurlHandleContainer [0x7fff755d1000] Returning connection handle 0x7f90bc00da00
[DEBUG] 2017-01-03 22:08:42 CurlHttpClient [0x7fff755d1000] Obtained connection handle 0x7f90bc00da00
[DEBUG] 2017-01-03 22:09:42 CurlHttpClient [0x7fff755d1000] Returned http response code 504
[DEBUG] 2017-01-03 22:09:42 CurlHttpClient [0x7fff755d1000] Releasing curl handle 0x7f90bc00da00
[DEBUG] 2017-01-03 22:09:42 CurlHandleContainer [0x7fff755d1000] Releasing curl handle 0x7f90bc00da00
[DEBUG] 2017-01-03 22:09:42 CurlHandleContainer [0x7fff755d1000] Notified waiting threads.
[DEBUG] 2017-01-03 22:09:42 AWSClient [0x7fff755d1000] Request returned error. Attempting to generate appropriate error codes from response
[ERROR] 2017-01-03 22:09:42 AWSClient [0x7fff755d1000] No response body. Response code: 504
的代碼是:
Aws::IoT::Model::UpdateThingRequest request;
Aws::IoT::Model::AttributePayload payload;
payload.AddAttributes("manufacturer",manufacturer);
payload.AddAttributes("product",product);
payload.AddAttributes("type",type);
payload.SetMerge(true);
request
.WithThingName(name)
.WithAttributePayload(payload);
auto outcome = _client->UpdateThing(request);
if (outcome.IsSuccess()) {
log.info("Sucess");
} else {
log.info("Error: %s: %s",outcome.GetError().GetExceptionName().c_str(),
outcome.GetError().GetMessage().c_str());
}
No response body?這似乎意外。我不知道這是否是一個假的錯誤代碼,在本地生成... –
我相信缺乏響應正文是由於超時。我需要更仔細地瞭解如何在SDK中實現POST交互。 –
實際上它看起來像是庫處理其他PATCH調用的方式。 POST方法工作正常。它似乎是等待PATCH正文的AWS REST服務,而不是由客戶端發送。 –