Skip to content

Failed setting TCP keep-alive interval with error code: 12018 #2563

Open
@azuraw10

Description

@azuraw10

Describe the bug

Creating an instance of Aws::Client::ClientConfiguration causes Failed setting TCP keep-alive interval with error code: 12018 warning message when region is fetched from the EC2 Instance Metadata Service. There is an option to get rid of the warnings by setting enableTcpKeepAlive to false once the object is created, but the problem is that the warnings are generated in the constructor and when executing the constructor enableTcpKeepAlive is always set to true. This causes problems on Windows, since the tcp keep alive setting on WinHttp is not available.

Expected Behavior

No warnings Failed setting TCP keep-alive interval with error code: 12018 should be generated. It should be possible to set enableTcpKeepAlive to false when creating the object (eg. pass enableTcpKeepAlive as a constructor parameter).

Current Behavior

Warning messages Failed setting TCP keep-alive interval with error code: 12018 are generated when Aws::Client::ClientConfiguration is created.

Reproduction Steps

int main()
{
    Aws::SDKOptions options;
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Warn;

    Aws::InitAPI(options);

    Aws::Client::ClientConfiguration config;
    config.enableTcpKeepAlive = false;

    ShutdownAPI(options);
}

Note: You need to make sure that the region will be fetched from the EC2 Instance Metadata Service.

Possible Solution

Since the tcp keep alive setting on WinHttp is not available, we can just set enableTcpKeepAlive to false by default on Windows:

@@ -45,7 +45,11 @@ void setLegacyClientConfigurationParameters(ClientConfiguration& clientConfig)
     clientConfig.httpRequestTimeoutMs = 0;
     clientConfig.requestTimeoutMs = 3000;
     clientConfig.connectTimeoutMs = 1000;
+    #ifdef _WIN32
+    clientConfig.enableTcpKeepAlive = false;
+    #else
     clientConfig.enableTcpKeepAlive = true;
+    #endif // _WIN32
     clientConfig.tcpKeepAliveIntervalMs = 30000;
     clientConfig.lowSpeedLimit = 1;
     clientConfig.proxyScheme = Aws::Http::Scheme::HTTP;

Another possibility is to pass enableTcpKeepAlive as a Aws::Client::ClientConfiguration constructor parameter.

Additional Information/Context

No response

AWS CPP SDK version used

1.9.234

Compiler and Version used

Microsoft Visual C++ Compiler 16.11.32228.343

Operating System and version

Windows Server 2022 20348.1607

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.p3This is a minor priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions