2

I am new to this IoT protocol area. My understanding is that MQTT is a lightweight messaging protocol for IOT devices.

MQTT over web socket involves use of HTTP to UPGRADE the connection to use web socket. Otherwise they follow same protocol for data exchange.

Both sit on top of the TCP layer.

Both support a persistent connection.

Both support pub/sub model.

The use case difference between the 2 is said to be that MQTT over web socket is ideal when client is a browser since it is difficult to implement MQTT in browser (but this can be made possible by using Socket API).

So what exactly is the technical difference between MQTT and MQTT over web socket that allows the later to be preferred by web browser apps?

hardillb
  • 12,813
  • 1
  • 21
  • 34
variable
  • 123
  • 4

1 Answers1

4

Nothing, as I stated in the answer on Stack Overflow they are byte for byte exactly the same protocol, it's just the transport layer which changes from raw TCP to Websockets.

The difference is that you CAN NOT open raw sockets from within the browser, the security sandbox will not allow you to open arbitrary TCP connections to random hosts. The sandbox will only allow HTTP based protocols, which includes WebSockets because they bootstrap from an initial HTTP request.

The other benefit of MQTT over Websockets is that it can make use of existing proxy infrastructure if needed.

hardillb
  • 12,813
  • 1
  • 21
  • 34