aws-sdk-cpp icon indicating copy to clipboard operation
aws-sdk-cpp copied to clipboard

How to process the warning about http://169.254.169.254

Open Andraw-sue opened this issue 3 years ago • 5 comments

Describe the bug

There are following warnings when I trigger http request, the http response is success, how to solve these warnings? [Warning] (AwsNativeSDK) - [AWS] ClientConfiguration - Retry Strategy will use the default max attempts. [Warning] (AwsNativeSDK) - [AWS] WinHttpSyncHttpClient - Failed setting TCP keep-alive interval with error code: 12018 [Warning] (AwsNativeSDK) - [AWS] WinHttpSyncHttpClient - Failed to add HTTP request headers with error code: 12150 [Warning] (AwsNativeSDK) - [AWS] WinHttpSyncHttpClient - Send request failed: [Warning] (AwsNativeSDK) - [AWS] EC2MetadataClient - Http request to retrieve credentials failed [Warning] (AwsNativeSDK) - [AWS] EC2MetadataClient - Request failed, now waiting 0 ms before attempting again. [Warning] (AwsNativeSDK) - [AWS] WinHttpSyncHttpClient - Failed setting TCP keep-alive interval with error code: 12018 [Warning] (AwsNativeSDK) - [AWS] WinHttpSyncHttpClient - Failed to add HTTP request headers with error code: 12150 [Warning] (AwsNativeSDK) - [AWS] WinHttpSyncHttpClient - Send request failed: [Warning] (AwsNativeSDK) - [AWS] EC2MetadataClient - Http request to retrieve credentials failed [Warning] (AwsNativeSDK) - [AWS] EC2MetadataClient - Can not retrieve resource from http://169.254.169.254/latest/meta-data/placement/availability-zone

Expected Behavior

There is no warning when request a http url successfully.

Current Behavior

There are some warnings when I trigger a http request.

Reproduction Steps

User CreateHttpRequest to trigger a http request.

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

AWSNativeSDK-1.9.50-rev2-windows

Compiler and Version used

Visual Studio 2019

Operating System and version

Windows 10

Andraw-sue avatar Oct 10 '22 06:10 Andraw-sue

Here is an example of how to process a warning from an http request:

    auto request = Aws::Http::CreateHttpRequest(Aws::String(
                                                        "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/samples/moviedata.zip"),
                                                Aws::Http::HttpMethod::HTTP_GET,
                                                Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);
    request->SetUserAgent("curl/7.79.1");
    std::cout << "Downloading the json file." << std::endl;
    auto response = httpClient->MakeRequest(request);

    if (Aws::Http::HttpResponseCode::OK == response->GetResponseCode()) {
        {

That is for dynamodb, but I would assume your request would look similar. You also said that you expect no warning, but a few things could be causing that. Can you make sure you have the correct credentials and that they have the resource that you are trying to access. Please include a minimal code snippet that reproduces this error if you are still running into the problem.

jmklix avatar Oct 11 '22 16:10 jmklix

Also you can set the environment variable AWS_EC2_METADATA_DISABLED to true to turn off the warning that you are seeing

jmklix avatar Oct 11 '22 23:10 jmklix

http://169.254.169.254/latest/meta-data/placement/availability-zone is used in some test cpp. Is there any other effect after setting the environment variable AWS_EC2_METADATA_DISABLED to true?

Andraw-sue avatar Oct 13 '22 13:10 Andraw-sue

You can search this sdk for all of the uses of AWS_EC2_METADATA_DISABLED. But I think the answer to your question is no, there are no other effects from setting this variable to true.

For example look in this file to see what is effected by this variable.

jmklix avatar Oct 13 '22 21:10 jmklix

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Oct 16 '22 00:10 github-actions[bot]