In my Node-RED flow, I have wired an IBM IoT Input node to an IBM IoT Output node. I am using mosquitto_pub
to publish to WIoTP so that the Node-RED flow is started. Similarly, I am using mqtt sub
(from mqttjs) to subscribe to the message from the Node-RED flow. However, I am not receiving payload on my subscription terminal window.
Publish
mosquitto_pub -h orgId.messaging.internetofthings.ibmcloud.com -p 8883 -i d:orgId:dType:default -u use-token-auth -P 'authToken' --cafile messaging.pem -t iot-2/evt/data/fmt/json -f payload.json
The IBM Input node subscribes to this device's ( d:orgId:dType:default
) data and forwards it to the IBM Output node where the device type is set to mobile
and event type is set to live
.
Subscribe
mqtt sub -h orgId.messaging.internetofthings.ibmcloud.com -p 443 -l wss -i a:orgId:default_mobile -u API-key -P 'API-token' --ca messaging.pem -t iot-2/type/mobile/id/default_mobile/evt/live/fmt/json
For subscription, I have created API keys and am using the same. What am I missing?
Answer by Nagesh_S (30) | Jul 20, 2018 at 12:14 PM
Thanks to @idan this problem is now resolved!
Devices (beginning with a d:
) can subscribe to iot-2/cmd
topic strings only.
I had wired the input node to output node directly. Therefore, all the settings in the output node were being overridden with msg.
attributes. So, I put in a function node that sets the msg.
attributes. Alternatively (as suggested by @idan), the function node can have a single line as msg=msg.payload
so that the attributes in the node are not overridden.
Answer by idani (624) | Jul 20, 2018 at 01:45 AM
the topic to which you subscribe does not look ok:
iot-2/type/mobile/id/default_mobile/evt/live/fmt/json
If you publish to iot-2/evt/data/fmt/json the the topic should look like (assuming that device type is mobile and device if is default_mobile)::
iot-2/type/mobile/id/default_mobile/evt/data/fmt/json
Answer by Nagesh_S (30) | Jul 20, 2018 at 03:38 AM
The IBM Output node has event type set to live
and device type set to mobile
. That is why I am subscribing to iot-2/type/mobile/id/default_mobile/evt/live/fmt/json
. And, the key point here is, to subscribe to this topic string over Websockets ( wss
).
mosquitto_ clients won't connect from AWS EC2. 2 Answers
Handling connect and disconnects with Watson IoT Platform 3 Answers
Internet of Things – IBM MQTT Servers, IBM IoT Foundation (BlueMix hosted) & IIB 1 Answer
IoT Watson Device Management: reboot request fails 1 Answer
How to communicate to beagle bone black using watson iot platform? 1 Answer