Running Eclipse HONO and Ditto on Google Cloud (6)

MichaelChi
Google Cloud - Community
1 min readAug 20, 2022

--

Now we have verified the end-to-end connectivity with HTTP client, what if my devices use MQTT ?

Eclipse HONO supports MQTT 3.1.1, to publish telemetry to the MQTT endpoint, there are some things to pay extra attention to.

  • clientId: The client id of the device should be gcp-nnection-name + p, for example, if you follow this tutorial , the connection name should be gcp-connection-org-eclipse-ditto , then the clientId specified in your MQTT client should be gcp-connection-org-eclipse-dittop
  • username: The user name of the device should be ${DEVICE-AUTH}@${TENANT}, if you followed the tutorial, it should be demo-device-001-auth@org.eclipse.ditto , where the demo-device-001 is the device identifier and the org.eclipse.ditto is the HONO tenant name.

Your MQTT connection option should be similar to this

const connectionArgs = {
host: ‘YOUR MQTT HOST URL’,
port: 1883,
clientId: ‘gcp-connection-org-eclipse-ditto’ + ‘p’,
username: `demo-device-001-auth@org.eclipse.ditto`,
password: ‘my-password’,
protocol: ‘mqtt’
};

To publish telemetry to Eclipse HONO you publish to the topic t/?content-type=application/json , Where

  • t is the topic name for authenticated devices. For more details please refer to Eclipse document.
  • /?content-type=application/json is optional to specify the telemetry is in JSON format.

To subscribes to notifications from Eclipse, for example, a command sent to the edge device, you subscribes to command///req/#

--

--