Subscriber not receiving MQTT Publish from Lambda function

0

Hi,

I am looking for some guidance on what I could be doing incorrectly with my AWS Lambda function. For context, I am publishing a MQTT message from an ESP32-S3 to a specified topic (e.g. client/url/get). Upon receiving a message to that topic I trigger my Lambda function that in turn publishes a pre-signed URL to a topic that my device is subscribed to (e.g. client/url/get/accept). I am able to trigger my Lambda function and a pre-signed URL is published to the "client/url/get/accept" topic when I view my MQTT Test Client, but I am not receiving any feedback on my device in regards to that publish. I can manually publish to the "client/url/get/accept" topic from the MQTT Test Client and am able to see that publish from my device but no luck with my AWS Lambda publish.

For my Lambda function I am using aws-sdk's "AWS.IotData" to publish to my topic.

Any help would be appreciated, please let me know if you need any more information.

  • Can you update your question with the IoT Policy that is attached to the clients principal (e.g. certificate)?

kevinah
asked a year ago515 views
2 Answers
0

There are a few possible issues that could be causing the problem you're experiencing with your AWS Lambda function:

MQTT protocol issues: It's possible that there is a problem with the MQTT protocol itself, such as a problem with the quality of service (QoS) level or with the way the messages are being sent and received.

AWS IoT issues: There could be a problem with your AWS IoT configuration, such as an issue with the policies or permissions that are set up for your device or with the MQTT broker itself.

Lambda function issues: It's also possible that there is an issue with your Lambda function code or with the way it is configured. For example, there may be a problem with the way you are using the AWS SDK to publish the message, or there may be a problem with the way the message is being formatted or sent.

To troubleshoot the problem, here are a few steps you can try:

Check the logs: Check the logs for your Lambda function to see if there are any error messages that could indicate the source of the problem.

Test the MQTT connection: Use a tool like MQTT.fx to test the MQTT connection between your device and the broker, to see if the connection is working correctly.

Check the AWS IoT configuration: Check the policies and permissions for your device and make sure that they are set up correctly. Also check the configuration of the MQTT broker to ensure that it is set up correctly.

Review your Lambda function code: Review your Lambda function code to make sure that you are using the AWS SDK correctly and that the message you are publishing is formatted correctly.

Mounick
answered a year ago
0

If you can publish to your device manually from the MQTT test console, then the issue is likely with the way your code is publishing the message. It sounds like the Lambda code is sending some data to the 'client/url/get/accept' topic since you can see that data in the test console. Some things you can check:

  1. Are you publishing the message as json from the Lambda function?
  2. Look at the AWS IoT and Lambda logs and in Cloudwatch
  3. Add some logging/print statements into your Lambda function so that you can see the output of each step from the code
  4. Can you add code to the esp32 device to dump whatever is received from the socket to the screen?

If not already, check out the sample code for Device SDK v2 basic Publish/Subscribe here

otl
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions