Reputation: 540
I am trying to publish a message to a topic using the AWS SNSClient from the c++ SDK.
Can someone help me to find a way to figure out what is wrong with my approach? The error message I am getting only says that the "endpoint could not be reached".
I am trying to figure out where my request hangs - in my point of view it could be one of the following:
Does someone know how I can debug my request and see what the issue is?
Thanks! My code looks something like this (api init and shutdown is omitted):
Aws::SNS::SNSClient client(credentials , config);
Aws::SNS::Model::PublishRequest pubReq;
pubReq.SetTopicArn("...");
pubReq.SetMessage("Test message");
pubOutcome = client.Publish(pubReq);
if(! pubOutcome.IsSuccess() ){
std::cout << "outcome: " << pubOutcome.GetError().GetMessage() << std::endl;
}
Upvotes: 1
Views: 583
Reputation: 81336
My guess without being able to see your code is that you have not specified the correct region. If your code hangs for a few seconds then this is most likely the problem.
Add a line of code like this before your create the SNS Client:
config.region = "us-west-2";
To enable debugging add this line before Aws::InitAPI(options)
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
The headers for logging:
#include <aws/core/utils/logging/DefaultLogSystem.h>
#include <aws/core/utils/logging/AWSLogging.h>
Then you can review the logfile that is generated. It will start with "aws_sdk"
I use Visual Studio, so I prefer to step into the code to figure out what is wrong. Sometimes it is simpler to review the logfile.
Upvotes: 3