MQTT, CoAP and HTTP

Once a device is on a network, it needs a way to send its data. MQTT, CoAP and HTTP each suit different kinds of device.

Core

MQTT publish/subscribe and CoAP request/response In MQTT a device publishes a message to a named topic on a broker, which forwards it to every subscriber of that topic, with three delivery levels, over TCP port 1883 or 8883 with TLS. In CoAP a client sends a request and the server sends a response, over UDP port 5683 or 5684 with DTLS. MQTT Publish/subscribe over TCP Port 1883, or 8883 with TLS Device publishes message to a named topic Broker forwards it Subscriber Subscriber Delivery levels QoS 0 at most once QoS 1 at least once QoS 2 exactly once MQTT 5.0 and 3.1.1 are OASIS standards; 3.1.1 is also ISO/IEC 20922. CoAP RFC 7252 REST-style request/response for constrained devices Client Server request response Over UDP: port 5683, or 5684 when secured with DTLS
In MQTT a device publishes to a topic on a broker that forwards it to that topic's subscribers; in CoAP a client sends a request and gets a response over UDP.

Key points

  1. MQTT is a publish/subscribe protocol: devices publish messages to named topics on a broker, which forwards them to subscribers. MQTT 5.0 and 3.1.1 are OASIS standards; 3.1.1 is also ISO/IEC 20922.12
  2. MQTT offers three delivery levels: QoS 0 (at most once), QoS 1 (at least once) and QoS 2 (exactly once).1
  3. The registered TCP ports are 1883 for MQTT and 8883 for MQTT over TLS.31
  4. CoAP (RFC 7252) is a REST-style request/response protocol for constrained devices that runs over UDP, on port 5683, or 5684 when secured with DTLS.43