0
votes

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
1

1 Answers

2
votes

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