Advantages of Websockets | disadvantages of Websockets
This page covers advantages and disadvantages of Websockets over HTTP used in IoT (Internet of Things). It mentions benefits or advantages of Websockets and drawbacks or disadvantages of Websockets.
What are Websockets?
Introduction:
Websockets is a technology for bidirectional communication over single (TCP) socket, a type of PUSH technology.
It is a protocol which provides bidirectional, full duplex communication channels over a single TCP socket.
It is designed to be implemented in web browsers and web servers, but it can be used by any client or server application.

The figure depicts messages exchanged between client and server. As shown websocket uses handshake messages to establish or open connection where as HTTP uses request-response messaging mechanism. HTTP is half duplex where as websocket is full duplex.
It is a protocol which enables developers to open a persistent connection and send data in realtime between a client and a server. Messages can be sent between the single TCP socket connection (simultaneously or back and forth).
Benefits or advantages of Websockets over HTTP
Following are the benefits or advantages of Websockets over HTTP:
➨It supports duplex communication.
➨Using websockets, one can send and receive data immediately faster than HTTP. Moreover they are faster than AJAX.
➨Cross origin communication (however this poses security risks).
➨Cross platform compatibility (web, desktop, mobile)
➨HTTP takes upto 2000 bytes of overhead where as websocket takes only 2 bytes.
➨Replace long polling
➨Websockets are data typed but AJAX calls can only send string datatypes.
Drawbacks or disadvantages of Websockets
Following are the drawbacks or disadvantages of Websockets:
➨Web browser must be fully HTML5 compliant.
➨Websockets has no success functions like AJAX.
➨Intermediary/Edge caching is not possible with websockets unlike HTTP.
➨To build even simple protocol of your own, one can not be able to use friendly
HTTP statuses, body etc.
➨If application does not require a lot of dynamic interaction,
HTTP is much simpler to implement.
Advantages and Disadvantages of other Sensor Types
AMQP and MQTT Related Links
AMQP vs JMS
MQTT protocol basics
MQTT vs HTTP
MQTT vs REST
What is difference between
MQTT vs HTTP Difference between OSI and TCPIP layers Difference between TCP UDP FTP vs HTTP FTP vs SMTP FTP vs TFTP ARP vs RARP NAT vs PAT RIP vs OSPF SLIP vs PPP IMAP4 vs POP3 IPV4 vs IPV6
IoT (Internet of Things) Wireless Technologies
➤WLAN
➤THREAD
➤EnOcean
➤LoRa
➤SIGFOX
➤WHDI
➤Zigbee
➤6LoWPAN
➤Zigbee RF4CE
➤Z-Wave
➤NFC
➤RFID
➤INSTEON