Ask HN: Using WebSockets instead of mqtt for IoT
I recently worked on a personal project where I wanted to connect multiple ESP32's to a web app. Previously I've used mqtt to do this and also done this in several work projects, but I decided to try something different and use websockets as ESP-IDF has a websocket client.
It worked really well and ended up in a much simpler setup, I didn't need an mqtt broker or a long running process listening to the broker, which meant it was much easier to deploy.
Previously I'd had to create a CA and generate self-signed certificates for each device, but with websockets this doesn't seem necessary and is handled transparently by the webserver.
A few other advantages are: - it can have actual end-to-end confirmation, unlike MQTT which is only between client and broker - port 443 won't be blocked - much easier to develop and test locally
So my question is, is anyone else doing this at scale, is there something I haven't thought of?
5 comments
[ 1.4 ms ] story [ 27.4 ms ] threadI wouldn't do it at scale. Message brokers are battle-hardened for messages at scale, have multiple communication styles, especially pub/sub. They are built for messages at scale.
My interest in Websockets is the same as yours — fewer components (no MQTT server). Works well for a simple message flow and I'm ok with reenventing pub/sub for a small number of devices.