Resources
About MQTT
1min
message queue telemetry transport (mqtt) is a publish/subscribe based lightweight protocol it is designed for machine to machine (m2m) telemetry in low bandwidth environments mqtt sits on top of the tcp/ip protocol this publish/subscribe protocol requires a message broker the broker distributes messages to the interested clients based on the topic of the message mqtt defines methods for the desired action to be performed on the client the different methods are connect waits for a connection to be established with the server disconnect waits for the mqtt client to finish the work and then for the tcp/ip session to disconnect subscribe waits for the completion of a subscribe or unsubscribe method unsubscribe it request the server to unsubscribe the client from one or more topic publish this method immediately returns to the application thread after passing the request to the mqtt client a mqtt client is a sensor that generally publishes messages to the broker the broker sends the message to the mqtt clients that have subscribed to receive the data note a mqtt client can publish, subscribe, or both a client agent is available in almost all programming languages and major operating systems topics are used for mqtt addressing the json file that is downloaded from the loop platform (when the device is deployed) contains the topic to which the data needs to be published and subscribed the user can also create a custom topic and define to publish or subscribe or both from acl (action control list) under project settings an mqtt broker is responsible for receiving all messages, filtering them and sending messages to all the subscribed clients the broker also does the authentication and authorization of the client the broker is also extensible, which allows integration of custom authentication, authorization, and integration of the clients the mqtt connection is always between a client and a broker, as no client connects to another client the client sends a connect message to the broker and broker response with a connack and the status once the connection is established, the broker keeps it open as long as the client does not send a disconnect command a client id it is the identifier for each of the mqtt clients that connects to the mqtt broker the id is unique per broker the broker identifies the client and the state of the client using the client id security the broker has a username and password for authentication of the client and authorization mqtts also uses tls/ssl certificates for authentication qos the quality of service tells the user regarding the guarantee of message delivery qos 0 at most once qos 1 at least once qos 2 exactly once the quality of service is important as it lets the client choose the qos level based on the application and network reliability alternate protocols include the amqp (advanced message queuing protocol), coap (constrained application protocol), and xmpp (extensible messaging and presence protocol)