Monitoring the connection of a connected product involves keeping track of its connectivity status to ensure it's functioning properly and staying connected to the network. By default, to each thing the Connection Status metric is made available, and automatically keep updated by the Servitly backend engine.
The Connection Status metric indicates whether a product is ONLINE or OFFLINE, and a value is stored whenever the status changes.
The metric is of INTEGER type, and each value returned corresponds to a precise status.
Value | Meaning |
-1 | UNREACHABLE |
0 | OFFLINE |
1 | ONLINE |
The status of the connection is updated automatically by Servitly, but by going into the connection status metric edit page, you can change how the status is kept up-to-date.
Timeout
The time after that, the thing is put in OFFLINE status if no more values have been sent by the thing. For instance, if a 2 hours timeout has been configured, the thing goes OFFLINE only 2 hours after the last received value. Take care to configure a timeout, which is in line with the urgency in detecting whether the object is connected or not.
LWT
With the Last Will and Testament feature of the MQTT protocol, it is possible to detect in real-time if a thing disconnects from the cloud. The LWT requires that, during the MQTT channel establishment, the thing publishes to a specific topic the WILL message. Generally this is done by the client, so it is enough to specify the LWT topic and message.
TOPIC: <PATH_PREFIX>/<USERNAME>/<ASSET_ID>/<LWT_PATH> { "will": true }
Other than the Path, you need also to specify the Path Prefix, which depends on the underlying MQTT broker:
IoT Connector | LWT Path Prefix |
Servitly Thing Connector | STC |
Everyware Device Cloud | $EDC |
Once the LWT is configured, in case the thing loses the cloud connection, the MQTT broker resends to the subscribers the WILL message notifying that the thing is OFFLINE.
Note that, the WILL message is sent to the subscribers only after one and a half keep alive periods has passed. For instance, if the keep-alive interval is 5 minutes, the WILL message is notified only 7:30 minutes after the thing has sent the last message (measure, keep-alive ping). So be careful to set the right connection keep-alive interval if you want a real-time (or near real-time) connection status update. It is suggested to avoid periodically sending the keep-alive PING even if the thing is publishing measures, generally, this is automatically handled by the MQTT library.
Optionally, if you are using Everyware Device Cloud, you can specify the Birth path, that allows collecting birth information sent when the thing connects to the cloud. The birth certificate can be used to send connectivity information (e.g. SIM ICCID, signal level).
Predefined Properties
Other than the metric, on each thing object there are two additional properties:
- connectionStatus: the last registered connection status value for the thing.
- connectionStatusLastUpdateTimestamp: the timestamp related to the last connection status change.
You can reference these properties into templates, for instance to sort/filter the thing list by connection status.
<thing-list-widget-v2>
<property name="name"></property>
<property name="serialNumber"></property>
<property name="connectionStatus" filter="connectionStatus"></property>
<thing-list-widget-v2
These properties are also available via API or into insights computation (Algorithm inputs).
Comments
0 comments
Please sign in to leave a comment.