I upload a file to S3. Directly after the request I get an exception from the MonitoringManager and I don't know what I am doing wrong. We are using multiple threads in our application.
Exception: Assertion failed. Program: ... Monitor...ger.cpp Line 55 Expresion: s_monitors
The cpp file: https://github.com/aws/aws-sdk-cpp/blob/master/aws-cpp-sdk-core/source/monitoring/MonitoringManager.cpp Line 55
uploadFileToS3(...);
method 'uploadFileToS3':
bool result = false;
const Aws::SDKOptions options;
Aws::InitAPI(options);
{
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("TransferTests", 4);
Aws::Transfer::TransferManagerConfiguration config(m_executor.get());
config.s3Client = client;
auto transmanager = Aws::Transfer::TransferManager::Create(config);
std::shared_ptr<Aws::Transfer::TransferHandle> handle = transmanager->UploadFile(fileDestination, Aws::String(S3_BUCKET_NAME),
Aws::String(s3key), Aws::String("multipart/form-data"), metadata);
handle->WaitUntilFinished();
result = isAwsActionSuccessful(handle) && boost::filesystem::remove(fileDestination);
}
Aws::ShutdownAPI(options);
return result;
The issue was that my application used multiple threads so the API was initialized and shutdown multiple times. The problem was solved when I executed the initialize / shutdown of the API just once in my application.