MQTT vs HTTP | Difference between MQTT and HTTP protocols
This page compares MQTT vs HTTP and mentions difference between MQTT and HTTP protocols.
The figure-1 depicts simple MQTT protocol architecture (broker based).
Following are the features of MQTT protocol:
• It is over TCP.
• It uses SSL/TLS for security.
• There are many messages used in MQTT protocol such as CONNECT, PUBLISH, SUBSCRIBE, DISCONNECT etc.
• Username/Password is used in 'connect' message.
• It encrypts payload i.e. it is payload agnostic.
• 1883 port is used by MQTT protocol.
Refer MQTT Protocol>> for more information.
The figure-2 depicts, HTTP connection between client (web user) and web server.
It uses normal IP header for routing of packets and data are not encrypted before transmission.
Refer HTTP vs HTTPS>> for more information.
Following table mentions comparison between MQTT and HTTP protocols.
|Full Form||Message Queue Telemetry Transport||Hyper Text Transfer Protocol|
|Design Methodology||The protocol is data centric.||The protocol is document centric.|
|Architecture||It has publish/subscribe architecture. Here devices can publish any topics and can also subscribe for any topics for any updates.||It has request/response architecture.|
|Data security||YES||NO, hence HTTPS is used to provide data security.|
|Upper layer protocol||It runs over TCP.||It runs over UDP.|
|message size||small, it is binary with 2Byte header.||Large, it is in ASCII format.|
|Libraries||30KB C, 100KB Java||Large|
|Port number||1883||80 or 8080|
|Data distribution||1 to 0/1/N||one to one only|