Direct MQTT vs MQTT over WebSocket


What are merits of MQTT over WebSocket compared to direct MQTT?

I'm considering using MQTT in my project and so I want to know why some people choose MQTT over WebSocket instead of direct MQTT.

Best Solution

You should only need to run MQTT over websockets if you intend to publish/subscribe to messages directly from within webapps (in page).

Basically I would run pure MQTT for everything and only add the websockets if you actually need it.

For all the non-browser languages the MQTT client libraries only use native MQTT. For Javascript there is both a pure MQTT library and the Paho in page library that uses websockets.

Edit: The firewall tunnelling use case is a valid reason to use MQTT over websockets and since writing this answer more of the none web/JavaScript client libraries have added support

Related Question