Comparison Between MQTT and WebSocket Protocols for IoT Applications Using ESP8266

As the Internet of Things becomes more popular, applications development using this concept are turning more and more common and accessible. Besides that, high performance and real-time applications require a low latency protocol. Taking these aspects into account, this work aims to compare the application layer network protocols: Message Queue Telemetry Transport and WebSocket, using ESP8266 (SoC with IEEE 802.11) and Node.js servers for data exchange, using the most popular protocol implementation found in Github, considering topics like documentation, round-trip time of packages using local network and memory allocated in a device. Experimental tests were performed to measure latency by calculating the time difference of packets exchanged between a server and an ESP8266 using both protocols. It has been found that the use of WebSocket is more appropriate than MQTT in applications with RTT of at least 1 millisecond according to the data and contexts presented in that article.