• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

290
Views
How to use MQTT-JS or JS AWS-SDK (node JS/JS) to send and receive data to a topic of AWS IoT

I am working on a project, in which I need to connect my devices via MQTT protocol to AWS IoT, to send and receive data.

So first I got my endpoint from the AWS Portal. Please check below screenshot: enter image description here

Then I tried using AWS Lambda for RnD purpose, and it is working as expected. Please check below screenshot, what code I did at AWS Lambda:

enter image description here

But now I want to integrate this at the device end.

I tried MQTT JS to connect devices to AWS IoT data. Please check below code: enter image description here

But this code is not working, no error I got in the output, Its just waiting.

In this code, I used the accessKey and secretKey, which I got after creating a user in AWS-IAM, with permission AWSIoTDataAccess.

I tried AWS-SDK also with the same IAM credentials. Please check below code. enter image description here

But unfortunately, it is also not working.

Note: My device is just a Windows system, which will send and receive data for a topic at AWS IoT.

Please help me to solve this. Don't know what I missed. Any suggestion will be helpful for me. Thanks,

EDIT:

After followed the steps mentioned here https://docs.aws.amazon.com/iot/latest/developerguide/device-certs-create.html, suggested in answer by @sokkasokka. Finally getting some error at least. Please check below screenshot for the edited code and error. enter image description here

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try creating AWS IoT Thing with proper permissions and use the certificates to authenticate your MQTT device.

https://docs.aws.amazon.com/iot/latest/developerguide/device-certs-create.html

And see this issue as well: Fail to connect to AWS IoT via mqtt.js

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error