Reputation: 2471
I created two devices to simulate a pub-sub scenario with mosquitto_pub
and mosquitto_sub
commands. The dashboard shows connected status for the terminal running mosquitto_sub
. The dashboard also shows the latest message sent by the terminal running mosquitto_pub
. And, yet the terminal running the subscription shows nothing.
What am I missing?
Subscription
mosquitto_sub -h orgId.messaging.internetofthings.ibmcloud.com -p 8883 -i d:orgId:dType:device01 -u use-token-auth -P token --cafile messaging.pem -t iot-2/evt/data/fmt/json
Publisher
mosquitto_pub -h orgId.messaging.internetofthings.ibmcloud.com -p 8883 -i d:orgId:dType:device02 -u use-token-auth -P token --cafile messaging.pem -t iot-2/evt/data/fmt/json -f some.json
Upvotes: 0
Views: 306
Reputation: 555
you cannot use a device clientID (e.g. d:orgId:dType:device01) to subscribe to a topic of a deviceid, that is not allowed. You need to use an application for this actions.
Check here for credentials and authentication: https://console.bluemix.net/docs/services/IoT/applications/mqtt.html#mqtt
Command should look like:
mosquitto_sub -h orgId.messaging.internetofthings.ibmcloud.com -p 8883 -i a:orgId:myapp -u <api-key e.g a-orgId-a84ps90Ajs > -P <api-token> --cafile messaging.pem -t iot-2/type/dType/id/device01/evt/data/fmt/json
Upvotes: 2