#readwise # MQTT - Wikipedia ![rw-book-cover](https://rdl.ink/render/https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMQTT) ## Metadata - Author: [[wikipedia.org]] - Full Title: MQTT - Wikipedia - URL: https://en.wikipedia.org/wiki/MQTT ## Summary MQTT is a lightweight, machine-to-machine network protocol designed for connections with devices that have limited resources or network bandwidth, such as in the Internet of Things (IoT). It is an open OASIS standard and ISO recommendation. MQTT was originally developed in 1999 to monitor oil pipelines within the SCADA industrial control system. The protocol provides publish-subscribe messaging and is used for efficient communication between MQTT brokers and clients. MQTT 5.0, released in 2019, introduced new features such as reason codes, shared subscriptions, message expiry, and support for MQTT over the QUIC transport protocol. The protocol supports different levels of quality of service (QoS) and can be secured using TLS encryption. ^l3yq7j ## Highlights **The MQTT protocol defines two types of network entities: a message broker and a number of clients. An MQTT broker is a server that receives all messages from the clients and then routes the messages to the appropriate destination clients. An MQTT client is any device (from a micro controller up to a fully-fledged server) that runs an MQTT library and connects to an MQTT broker over a network.** ([View Highlight](https://read.readwise.io/read/01hprnmee89az469fzqtjdet59)) ^ck0srh --- **Information is organized in a hierarchy of topics.** When a publisher has a new item of data to distribute, it sends a control message with the data to the connected broker. The broker then distributes the information to any clients that have subscribed to that topic. **The publisher does not need to have any data on the number or locations of subscribers, and subscribers, in turn, do not have to be configured with any data about the publishers.** ([View Highlight](https://read.readwise.io/read/01hprnnyfz4dact4qkt0t0nwsa)) --- **If a broker receives a message on a topic for which there are no current subscribers, the broker discards the message unless the publisher of the message designated the message as a retained message.** A retained message is a normal MQTT message with the retained flag set to true. The broker stores the last retained message and the corresponding [quality of service](https://en.wikipedia.org/wiki/Quality_of_service) (QoS) for the selected topic. **Each client that subscribes to a topic pattern that matches the topic of the retained message receives the retained message immediately after they subscribe.** The broker stores only one retained message per topic. This allows new subscribers to a topic to receive the most current value rather than waiting for the next update from a publisher. ([View Highlight](https://read.readwise.io/read/01hprnq8jgx3wk62s35s08rsjh)) --- When a publishing client first connects to the broker, it can set up a default message to be sent to subscribers if the broker detects that the publishing client has unexpectedly disconnected from the broker. ([View Highlight](https://read.readwise.io/read/01hprnrdbxfdw55deb13b14jsc)) --- **Each connection to the broker can specify a QoS measure.** These are classified in increasing order of overhead: - **At most once – the message is sent only once and the client and broker take no additional steps to acknowledge delivery (fire and forget).** - **At least once – the message is re-tried by the sender multiple times until acknowledgement is received (acknowledged delivery).** - **Exactly once – the sender and receiver engage in a two-level handshake to ensure only one copy of the message is received (assured delivery).** ([View Highlight](https://read.readwise.io/read/01hprnzwvmk6wjz1778j8mxt7v)) ---