Hacker News new | ask | show | jobs
by mmzeeman 1577 days ago
The best way to do pub/sub on the web with a standard protocol is MQTT (https://mqtt.org). It supports websockets, it scales, supports authentication, can handle unreliable networks.

We use it exclusively for the soon to be released 1.0 version of Zotonic. See: https://test.zotonic.com (running on a 4.99 euro Hetzner vps).

We developed an independent support javascript library called Cotonic (https://cotonic.org) to handle pub/sub via MQTT. This library can also connect to other compliant MQTT brokers. Because MQTT is fairly simple protocol, it is fairly easy to integrate in existing frameworks. Here is an example chat application (https://cotonic.org/examples/chat) which uses the open Eclipse broker.

2 comments

> The best way to do pub/sub on the web with a standard protocol is MQTT

Strong disagree. MQTT has no place in a world with WebSockets. MQTT knowledge is so esoteric in comparison. Maybe it's the Haskell of transport protocols: really friggin smart, but not if you're trying to be useful to society at large.

MQTT is a proven protocol. It's design started started more than 20 years ago. The protocol was designed to be easy to implement. It is simple to implement if you want. There are multiple brokers, and client libraries available. So why invent a new protocol, when an open, standardised protocol already exists.

Open pages in a browser are not that different from IoT devices.

> So why invent a new protocol, when an open, standardised protocol already exists.

Because despite being a dinosaur, it still only has middling adoption. It exists in a particular niche of a particular niche of computing.

HTTP, in contrast, is English to MQTT's German. One is just infinitely more common and accessible to the majority of the world. So, if you're serious, use it.

There is no efficient pub/sub functionality in HTTP.
MQTT is neither "esoteric" or "not useful to society at large" nor is WebSockets vs MQTT even a useful contrast, since WebSockets to a large degree addresses a different level of the stack (and indeed "MQTT over WebSockets" is a common way of deploying it).
Look at your first two sentences. You say MQTT supports authentication like MQTT.