What is the difference between MQTT, Socket, and WebSocket?

Il MQTT protocol is an application layer protocol. The MQTT protocol is a protocol designed for communication with a large number of remote sensors and control devices with limited computing power and working on low-bandwidth, unreliable networks. It has the following main characteristics:

● Use the publish/subscribe messaging model to provide one-to-many message publishing and decouple applications;

● Message transmission with masked payload content;

● Use TCP/IP to provide network connectivity;

● There are three types of message publishing service quality:

“At most once”, message publishing completely relies on the underlying TCP/IP network. Message loss or duplication can occur. This level can be used in situations where, for environmental sensor data, it doesn’t matter if a read record is lost because a second one will be sent soon.

“At least once” ensures that the message arrives, but message duplication may occur.

“Only once” ensures that the message arrives once. This level can be used in situations where duplication or loss of messages can lead to incorrect results in a billing system.

What is the difference between MQTT, Socket, and WebSocket?

Socket is an encapsulated interface for the TCP/IP protocol suite, and TCP links can be operated through Socket. Socket connections can specify different transport layer protocols, namely TCP or UDP, so when TCP is used to establish a connection, the Socket connection is regarded as a TCP connection.

WebSocket is at the application layer, the same level as HTTP, and is based on the TCP protocol. The difference between WebSocket and HTTP is that WebSocket is a full-duplex communication, that is, the server and the client can transmit messages to each other at the same time.

Contatto