AWS SNSClient publish call could not reach endpoint - c++

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:
the docker container the c++ app is running in is blocking the requests somehow (new to docker)
the client configuration is wrong (region, arn, creditials wrong?)
the request is malformed (some parameters not set? Message type maybe?)
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;
}

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.

Related

Testing Grafana alert returns "Failed to test the rule" with 500 - Internal Server Error response

I'm trying to set up alerts on one of my graphs. I'm using AMG (Amazon Managed Grafana). However, I'm getting "Failed to test the rule" notification. When I inspect HTTP response, it shows
Status Code: 500 Internal Server Error
{"message":"Failed to test rule"}
URL
https://g-39e1d60d36.grafana-workspace.us-east-1.amazonaws.com/api/alerts/test
Here is my alert setup (even If I try something super simple, still getting the same issue):
To me, it seems like Grafana internal error/bug, does anyone experience a similar issue and know the potential resolution?
For us the solution was to not set the datasource dynamically from the environment variable we added in the interface. When we moved the target query to a fixed datasource, it all worked ok.

Mysterious 500 error with AWS Lambda; unable to debug

I have an API that I host using Lambda (nodejs), with API-gateway. I'm using serverless to deploy.
Generally things have been fine, but while I was working on a specific function today, I started to receive HTTP 500 errors when hitting the endpoint. However, while there were still API-Gateway access logs for the end point, there were no Cloudwatch logs for the lambda functions getting hit. I was able to verify that the Authorizer was getting hit successfully, and not returning any issue (if it was, it would have been a 401). After using CLI tools to invoke the function from the command line, the 500 error went away and I was able to successfully hit the endpoints again.
Has anyone ever ran into this before? If I'm missing a debug step, I would really like to know. It was really concerning that my API could be generating 500 errors with no paper trail to help me understand what was happening.
You can check your role and permissions ,this link could help you https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-lambda-stage-variable-500/
Also you can debug further with X-ray : https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html

Send message into SQS from LAmbda with AWS-SDK-CPP

I want to send message to AWS SQS from AWS Lambda with a c++ application using the aws-sdk-cpp 1.8.154.
The related code:
Aws::Client::ClientConfiguration clientConfig("default");
Aws::SQS::SQSClient sqs(clientConfig);
Aws::SQS::Model::SendMessageOutcome ret = sqs.SendMessage(sqsRequest);
BOOST_LOG_TRIVIAL(info) << "Send result with: " << ret.GetError().GetMessage();
and I get the following output:
curlCode: 77, Problem with the SSL CA cert (path? access rights?)
If I disable SSL verification, everything works fine.
I have tried to set
clientConfig.caPath = "/etc/ssl/certs/";
or
clientConfig.caFile = "/etc/ssl/certs/ca-certificates.crt";
without success.
The lambda execution role has AmazonSQSFullAccess, but it doesn't help.
Can anybody help me how to get things work?
The only strong related issue that I found: https://github.com/awslabs/aws-lambda-cpp/issues/95 but the questioner didn't provided the resolution.
The solution worked for me is on page: https://github.com/awslabs/aws-lambda-cpp
Setting the CA correctly:
Aws::Client::ClientConfiguration config;
config.caFile = "/etc/pki/tls/certs/ca-bundle.crt";

Amazon Connect - cannot debug error in Get Customer Input Stage

I am just new to Amazon Connect and Lex and have just starting creating simple projects. I already have created an entire contact flow which uses Lex and Lambda for routing. Problem is in the "Get Customer Input" stage, it seems to always go to the error output and I could not figure out why. I tried to check if there's any way I can find logs for each stages in the contact flow but could not find any.
Can anyone help me solve this issue? I need to see logs to find out the cause of the error.
EDIT: I got the contact flow logs from cloudwatch. See below. I can't find any significant error from it.
{
"Results": "Error",
"ContactId": "<contact-id>",
"ContactFlowId": "<the contact flow id>",
"ContactFlowModuleType": "GetUserInput",
"Timestamp": "2019-07-08T08:27:01.185Z"
}
You might be getting error because you are getting error from your Lex and that is why the flow is going in error.
You can check the logs for connect and Lex in Amazon service - Amazon CloudWatch.
You can also provide details from logs/screenshot what exactly error you are getting, so that I can help.
This might be due to language settings mismatch.
If you're using LexV2 make sure you set the proper Language Attribute as well. Easiest way is using the set Voice block in your Contact Flow, on the very bottom of the block you can enable "set language attribute".
Original answer: https://repost.aws/questions/QUn9bLLnclQxmD_DMBgfB9_Q/amazon-connect-error-using-lex-as-customer-input

Unable send a message with stompclient

Iam trying to send a message to activemq using pythons stompclient.
https://bitbucket.org/hozn/stompclient/wiki/User%20Documentation
If there is a better library for this Im open to suggestions.
If i change to ip or port it will fail to connect so im assuming that the connection is working. There are no errors when I run this code its just that I see no messages on the queue. I think the destination path is possibly where it is failing the PhysicalName of the activemq queue is in this pattern 'abc.queue_name'.
I've tried the following destinations
/queue/abc/queue_name
/queue/abc.queue_name
abc.queue_name
Any suggestions are greatly appreciated.
Thanks
from stompclient import PublishClient
client = PublishClient('IP', 53680)
response = client.connect('defaultPassword', 'defaultUser')
reponse1 = client.send('/queue/abc/queue_name', 'bla')
time.sleep(5)
Have you checked the webconsole to see if your Queue was created by the send?
You should also try adding a request id onto the send and waiting for a response, this will ensure that the broker has enough time to get the sent data before you client code disconnects.
You might also want to check the Broker logs to see if any errors are logged or any security warnings in case the user doesn't have publish rights.
Added this property to the activemq.xml file and im now seeing messages on the queue via the web console.
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613"/>