MQTT
MQTT is a lightweight messaging protocol based on agent publishing / subscribing for low bandwidth and intermittent communication. MQTT Server provides MQTT client-side with 3.1 compatible MQTT API interface service that support QoS 0, QoS 1 messaging service quality.
Log into IoT cloud platform, visit developer
page, in basic settings
section, you will receive the AppID (application identifier - MQTT username/clientId), AppSecret(message password signature - MQTT password). In “MQTT settings”, you can configure message transmission quality (note that during beta phase, server side default quality is QoS 0). In message push settings
, if you set message transmission to safe mode
, MQTT will apply the same encryption method for data transmission.
MQTT BROKER IP | Interface | Encryption: Yes/No |
---|---|---|
iot.sensoro.com | 1883 | Encryption under safe mode |
1. Client-Side Settings
To connect to our MQTT server, you need to configure username, password, clientId and other setting of your MQTT client by the way described below:
Use AppID as MQTT username
Use AppSecret as MQTT password
MQTT clientID need any string match the regexp
^#AppID#(\/[-_0-9a-zA-Z]{0,36})?$
(e.g. suppose your AppID isfoobar
, clientid need to match^foobar(\/[-_0-9a-zA-Z]{0,36})?$
. bothfoobar
,foobar/
andfoobar/abc
are valid client id).
Note:
If there're multiple MQTT clients configured with same AppID, make sure that they're configured with different clientId.
If connection was established but closed immediately with message
[Error: Connection refused: Not authorized]
,please make sure you have provided the correct username, password and clientid.
NodeJS Sample code as below:
2. Sensor Data Push and Receive (/users/:APPID/devices)
MQTT Client-side leverages /users/:APPID/devices
topic to receive data push from sensors, and this data format is consistent with the format of Webhook(custom callback URL) data push.