Hello People. This article discusses about Communication protocols for IoT devices on AWS. As you know, AWS IoT Core supports devices and clients that use the MQTT and the MQTT over WebSocket Secure (WSS) protocols to publish and subscribe to messages, and devices and clients that use the HTTPS protocol to publish messages. All protocols support IPv4 and IPv6.
You can connect to AWS account's device endpoints. See here AWS IoT device data and service endpoints for information about how to find your account's device endpoints.
Choose a protocol for your device communication
For most IoT device communication through the device endpoints, it is better to use the MQTT or MQTT over WSS protocols; however, the device endpoints also support HTTPS.
There is no guarantee that HTTPS connections would last any longer than the time it takes to receive and respond to requests. MQTT connection duration on the other hand depends on the authentication feature that you use.
With X.509 certificates and custom authentication, connection duration has no hard limit. But even then it can be as short as a few minutes. Reason being that connection interruptions can occur for various reasons.
AWS IoT can publish lifecycle events on the MQTT topics. These events are available by default and you cannot disable them.
AWS IoT publishes a message to the following MQTT topics when a client connects or disconnects:
$aws/events/presence/connected/– A client connected to the message broker.
$aws/events/presence/disconnected/– A client disconnected from the message broker.
A connect message has the following structure.
"clientId": "186b5", "timestamp": 1573002230757, "eventType": "connected", "sessionIdentifier": "a4666d2a7d844ae4ac5d7b38c9cb7967", "principalIdentifier": "12345678901234567890123456789012", "ipAddress": "192.0.2.0", "versionNumber": 0
A disconnect message has the following structure.
"clientId": "186b5", "timestamp": 1573002340451, "eventType": "disconnected", "sessionIdentifier": "a4666d2a7d844ae4ac5d7b38c9cb7967", "principalIdentifier": "12345678901234567890123456789012", "clientInitiatedDisconnect": true, "disconnectReason": "CLIENT_INITIATED_DISCONNECT", "versionNumber": 0
AWS IoT publishes a message to the following MQTT topic when a client subscribes or unsubscribes to an MQTT topic:
clientId is the MQTT client ID that connects to the AWS IoT message broker.
Hope this article on Communication protocols for IoT devices on AWS is useful to you. Please read about AWS IoT actions and core related services.