0
votes

I am using MQTTJS client to publish and subscribe to my IoT topics from react application.

I tried to use MQTTJS to get/update my AWS device shadow but I can't send or receive anything from my device shadow. here is my code

client.publish('$aws/things/things/deviceId/shadow/get', {});
1
@cementblocks I updated the topic but I still go no response - Mohammed
Show your complete code. - cementblocks

1 Answers

0
votes

If you also using cognito, you can connect, subscribe, and publish topics using this framework: https://github.com/jimmyn/aws-mqtt-client

or just use MQTTJS

Either way I would check to make sure you have created a iot policy to allow access to the topics your trying to publish to. As seen here: https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html

You'll also need to make sure you have created a role with an IAM policy that allows access to iot; that can be attached to whatever credentials you used to auth the MQTTclient.