aws/aws-sdk-cpp

win7 system cannot upload minio issue

yxl-Devin opened this issue · 2 comments

Describe the bug

I encountered a network issue while uploading mini using the SDK. As Win7 does not support HTTP/2, HTTP/1.1 was used here,
Here are the relevant logs
Then the upload failed, using S3 Browser can upload normally

Expected Behavior

I hope the file can be uploaded to Minio

Current Behavior

[DEBUG] 2023-11-29 12:35:02.216 WinHttpSyncHttpClient [9540] Closing http request handle 0000000002DAA0C0
[DEBUG] 2023-11-29 12:35:02.216 WinHttpSyncHttpClient [9540] Releasing connection handle 0000000000438A10
[DEBUG] 2023-11-29 12:35:02.216 WinHttpConnectionPoolMgr [9540] Releasing connection to endpoint 169.254.169.254:80
[ERROR] 2023-11-29 12:35:02.216 EC2MetadataClient [9540] Http request to retrieve credentials failed
[WARN] 2023-11-29 12:35:02.216 EC2MetadataClient [9540] Request failed, now waiting 0 ms before attempting again.
[TRACE] 2023-11-29 12:35:02.217 WinHttpSyncHttpClient [9540] Making PUT request to uri http://169.254.169.254/latest/api/token
[INFO] 2023-11-29 12:35:02.217 WinHttpConnectionPoolMgr [9540] Attempting to acquire connection for 169.254.169.254:80
[DEBUG] 2023-11-29 12:35:02.217 WinHttpConnectionPoolMgr [9540] Pool found, reusing
[INFO] 2023-11-29 12:35:02.217 WinHttpConnectionPoolMgr [9540] Connection now available, continuing.
[DEBUG] 2023-11-29 12:35:02.217 WinHttpConnectionPoolMgr [9540] Returning connection handle 0000000000438A10
[DEBUG] 2023-11-29 12:35:02.217 WinHttpSyncHttpClient [9540] Acquired connection 0000000000438A10
[WARN] 2023-11-29 12:35:02.217 WinHttpSyncHttpClient [9540] Failed setting TCP keep-alive interval with error code: 12009
[ERROR] 2023-11-29 12:35:02.217 WinHttpHttp2 [9540] Failed to enable HTTP/2 on WinHttp handle: 0000000002DAFB90. Falling back to HTTP/1.1.
[DEBUG] 2023-11-29 12:35:02.217 WinHttpSyncHttpClient [9540] AllocateWindowsHttpRequest returned handle 0000000002DAFB90
[DEBUG] 2023-11-29 12:35:02.217 WinHttpSyncHttpClient [9540] with headers:
[DEBUG] 2023-11-29 12:35:02.217 WinHttpSyncHttpClient [9540] host: 169.254.169.254
user-agent: aws-sdk-cpp/1.11.169 Windows/6.1.7601.18015 AMD64 MSVC/1929
x-aws-ec2-metadata-token-ttl-seconds: 21600

[WARN] 2023-11-29 12:35:03.215 WinHttpSyncHttpClient [9540] Send request failed:       ʱ

[DEBUG] 2023-11-29 12:35:03.215 WinHttpSyncHttpClient [9540] Closing http request handle 0000000002DAFB90
[DEBUG] 2023-11-29 12:35:03.215 WinHttpSyncHttpClient [9540] Releasing connection handle 0000000000438A10
[DEBUG] 2023-11-29 12:35:03.215 WinHttpConnectionPoolMgr [9540] Releasing connection to endpoint 169.254.169.254:80

Reproduction Steps

bool UploadS3::UploadResumable()
{
    qDebug()<<"UploadS3 UploadResumable";
    qDebug()<<"m_strBucketName=="<<m_strBucket.c_str();
    qDebug()<<"m_strPathKey=="<<m_strPathKey.c_str();
    qDebug()<<"m_strAccessKeyId=="<<m_strAccessKeyId.c_str();
    qDebug()<<"m_strAccessKeySecret=="<<m_strAccessKeySecret.c_str();
    qDebug()<<"m_ui64PartSize=="<<m_i64PartSize;
    qDebug()<<"m_ui32ThreadNum=="<<m_ui32ThreadNum;
    qDebug()<<"m_strEndpoint=="<<m_strEndpoint.c_str();
    qDebug()<<"m_strKeyUrl=="<<m_strKeyUrl.c_str();

    // use default credential provider chains
    Aws::Auth::AWSCredentials awsCredentials(m_strAccessKeyId.c_str(), m_strAccessKeySecret.c_str());
    Aws::Client::ClientConfiguration clientConfiguration;
    //clientConfiguration.region = "<your-region>";
    clientConfiguration.httpRequestTimeoutMs = 30000;
    clientConfiguration.requestTimeoutMs = 30000;
    clientConfiguration.connectTimeoutMs = 10000;
    clientConfiguration.endpointOverride = m_strEndpoint;  //上传的IP和端口,域名跳转可能有问题
    clientConfiguration.scheme = Aws::Http::Scheme::HTTP;
    clientConfiguration.verifySSL = false;
    clientConfiguration.enableTcpKeepAlive = false;

    auto m_pS3Client = std::make_shared<Aws::S3::S3Client>(awsCredentials, clientConfiguration, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, false);
    auto executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("executor", 25);
    Aws::Transfer::TransferManagerConfiguration transferManageConfig(executor.get());
    transferManageConfig.uploadProgressCallback = std::bind(&UploadS3::UploadProgressCallback, this,
                                                            std::placeholders::_1, std::placeholders::_2);
    transferManageConfig.s3Client = m_pS3Client;

    auto transferManager = Aws::Transfer::TransferManager::Create(transferManageConfig);

    m_uploadHandle = transferManager->UploadFile(m_strPathKey, m_strBucket, m_strKeyUrl, Common::GetInstance()->GetMinioUploadHeader().toStdString(), Aws::Map<Aws::String, Aws::String>());
    m_uploadHandle->WaitUntilFinished();
    bool success = m_uploadHandle->GetStatus() == Aws::Transfer::TransferStatus::COMPLETED;

    if (!success)
    {
        auto err = m_uploadHandle->GetLastError();
        qDebug()<<"File upload failed:  "<<(int)err.GetErrorType();
        qDebug()<<"File upload failed:  "<<err.GetMessage().c_str();
        return false;
    }
    return true;
}

Possible Solution

The Win7 system is unable to upload files properly

Additional Information/Context

We found that this bug may be related to HTTP/1.1

AWS CPP SDK version used

Compiled using source code

Compiler and Version used

VS2019

Operating System and version

Win7 version 6.1 build 7601: Service Pack 1

Thanks for this issue and filling out the template. This looks like it might be a problem with minio. We can't guarantee that this sdk is compatible with minio, so you might need to reach out to them. I can help you if you still see problems when uploading directly to s3. Can you reproduce this error using aws s3? You can find all of the s3 samples here

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.