Click Below to Get the Code

Browse, clone, and build from real-world templates powered by Harper.
Tutorial
GitHub Logo

A Simpler Real-Time Messaging Architecture with MQTT, WebSockets, and SSE

Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.
Harper Learn
Tutorial
Harper Learn

A Simpler Real-Time Messaging Architecture with MQTT, WebSockets, and SSE

Ivan R. Judson, Ph.D.
Distinguished Solution Architect
at Harper
December 19, 2025
Ivan R. Judson, Ph.D.
Distinguished Solution Architect
at Harper
December 19, 2025
Ivan R. Judson, Ph.D.
Distinguished Solution Architect
at Harper
December 19, 2025
December 19, 2025
Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.
Ivan R. Judson, Ph.D.
Distinguished Solution Architect

👉 Follow along with the code: https://github.com/HarperFast/mqtt-getting-started


If you want to run everything you see in the video yourself, start with the repository above. It contains a working example of Harper acting as a real-time backbone—brokering MQTT, WebSockets, and Server-Sent Events, while also persisting data in one place.

This post is here to answer a slightly bigger question:

Why would you want to build something like this in the first place?

Problem: Real-Time Is Fragmented

Most real-world systems don’t use just one real-time protocol.

You might have:

  • Devices publishing telemetry over MQTT
  • Browsers consuming live updates over WebSockets
  • Dashboards or services subscribing via HTTP events
  • Applications that need the data stored for querying, replay, or recovery

Traditionally, these concerns get split apart:

  • A broker handles MQTT
  • A database stores the data
  • A separate service fans events out to clients
  • More glue connects everything together

Each piece works—but the system becomes harder to reason about, harder to scale, and harder to change.

What we’re exploring here is a simpler model:
one runtime that handles messaging, fan-out, and persistence together.

What Harper Is Doing Differently

In this setup, Harper sits in the middle as a real-time backbone, not just a message broker.

That means:

  • MQTT clients can publish and subscribe directly to Harper
  • WebSocket clients can publish and subscribe to the same resources
  • Server-Sent Events clients can subscribe over plain HTTP
  • Messages are persisted automatically as structured data
  • Every protocol sees the same events, in real time

There’s no translation layer and no external sync process. Once a message arrives, it’s immediately usable everywhere.

Getting Started: Minimal Setup, Real Results

Most of this works with almost no configuration.

In config.yml, enabling REST is enough:

rest: true


This turns on:

  • WebSocket support
  • Server-Sent Events
  • Resource-based pub/sub

MQTT support is already enabled by default.

From there, we define a couple of tables in schema.graphql:

type topics @export {
  id: ID!
}

type sensors {
  id: ID!
  location: String
  temperature: Float
}

The exported topics table enables wildcard subscriptions, while sensors gives us a place to persist incoming telemetry.

This is important: messages aren’t ephemeral. They’re stored, queryable, and replayable.

Publish Once, Use Everywhere

An MQTT publisher sends sensor data:

{
  "id": "sensor-101",
  "location": "lab",
  "temperature": 97.2
}

That single publish:

  • Updates the sensors table
  • Notifies MQTT subscribers
  • Pushes updates to WebSocket clients
  • Streams events to Server-Sent Events clients

For example, a WebSocket client can subscribe with:

ws://localhost:9926/sensors/sensor-101

And an SSE client uses the same resource over HTTP:

http://localhost:9926/sensors/sensor-101

Same data. Same topic. Different protocols.

Why This Matters in Practice

This pattern shows up in a lot of real systems:

  • IoT and edge telemetry, where devices publish over MQTT but humans consume data in browsers
  • Operational dashboards, where live data and historical data must stay in sync
  • Event-driven applications, where services need both real-time notifications and durable state
  • Distributed systems, where reducing moving parts directly improves reliability

By collapsing messaging, storage, and fan-out into one runtime, Harper makes these systems easier to build and easier to operate.

You spend less time wiring infrastructure together—and more time building the application logic that actually matters.

What Comes Next

In the next step (and the next video), we build an application that listens to these table-level events directly inside Harper. That’s where this turns from “broker demo” into a full event-driven application model.

Until then, clone the repo, run it locally, and watch the data flow.

Take a breath. Grab a cup of tea.
And enjoy building simpler real-time systems

👉 Follow along with the code: https://github.com/HarperFast/mqtt-getting-started


If you want to run everything you see in the video yourself, start with the repository above. It contains a working example of Harper acting as a real-time backbone—brokering MQTT, WebSockets, and Server-Sent Events, while also persisting data in one place.

This post is here to answer a slightly bigger question:

Why would you want to build something like this in the first place?

Problem: Real-Time Is Fragmented

Most real-world systems don’t use just one real-time protocol.

You might have:

  • Devices publishing telemetry over MQTT
  • Browsers consuming live updates over WebSockets
  • Dashboards or services subscribing via HTTP events
  • Applications that need the data stored for querying, replay, or recovery

Traditionally, these concerns get split apart:

  • A broker handles MQTT
  • A database stores the data
  • A separate service fans events out to clients
  • More glue connects everything together

Each piece works—but the system becomes harder to reason about, harder to scale, and harder to change.

What we’re exploring here is a simpler model:
one runtime that handles messaging, fan-out, and persistence together.

What Harper Is Doing Differently

In this setup, Harper sits in the middle as a real-time backbone, not just a message broker.

That means:

  • MQTT clients can publish and subscribe directly to Harper
  • WebSocket clients can publish and subscribe to the same resources
  • Server-Sent Events clients can subscribe over plain HTTP
  • Messages are persisted automatically as structured data
  • Every protocol sees the same events, in real time

There’s no translation layer and no external sync process. Once a message arrives, it’s immediately usable everywhere.

Getting Started: Minimal Setup, Real Results

Most of this works with almost no configuration.

In config.yml, enabling REST is enough:

rest: true


This turns on:

  • WebSocket support
  • Server-Sent Events
  • Resource-based pub/sub

MQTT support is already enabled by default.

From there, we define a couple of tables in schema.graphql:

type topics @export {
  id: ID!
}

type sensors {
  id: ID!
  location: String
  temperature: Float
}

The exported topics table enables wildcard subscriptions, while sensors gives us a place to persist incoming telemetry.

This is important: messages aren’t ephemeral. They’re stored, queryable, and replayable.

Publish Once, Use Everywhere

An MQTT publisher sends sensor data:

{
  "id": "sensor-101",
  "location": "lab",
  "temperature": 97.2
}

That single publish:

  • Updates the sensors table
  • Notifies MQTT subscribers
  • Pushes updates to WebSocket clients
  • Streams events to Server-Sent Events clients

For example, a WebSocket client can subscribe with:

ws://localhost:9926/sensors/sensor-101

And an SSE client uses the same resource over HTTP:

http://localhost:9926/sensors/sensor-101

Same data. Same topic. Different protocols.

Why This Matters in Practice

This pattern shows up in a lot of real systems:

  • IoT and edge telemetry, where devices publish over MQTT but humans consume data in browsers
  • Operational dashboards, where live data and historical data must stay in sync
  • Event-driven applications, where services need both real-time notifications and durable state
  • Distributed systems, where reducing moving parts directly improves reliability

By collapsing messaging, storage, and fan-out into one runtime, Harper makes these systems easier to build and easier to operate.

You spend less time wiring infrastructure together—and more time building the application logic that actually matters.

What Comes Next

In the next step (and the next video), we build an application that listens to these table-level events directly inside Harper. That’s where this turns from “broker demo” into a full event-driven application model.

Until then, clone the repo, run it locally, and watch the data flow.

Take a breath. Grab a cup of tea.
And enjoy building simpler real-time systems

Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.

Download

White arrow pointing right
Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.

Download

White arrow pointing right
Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.

Download

White arrow pointing right

Explore Recent Resources

Blog
GitHub Logo

The Nearstore Agent: a reference pattern for low-latency, geofenced, promotional decisions

Build a real-time, geofenced promo engine on Harper's agentic runtime. The Nearstore Agent collapses geofence lookup, customer data, campaigns, and AI decisions into a single process. Clone the reference repo and deploy in minutes.
Blog
Build a real-time, geofenced promo engine on Harper's agentic runtime. The Nearstore Agent collapses geofence lookup, customer data, campaigns, and AI decisions into a single process. Clone the reference repo and deploy in minutes.
Person with short dark hair and moustache, wearing a colorful plaid shirt, smiling outdoors in a forested mountain landscape.
Aleks Haugom
Senior Manager of GTM
Blog

The Nearstore Agent: a reference pattern for low-latency, geofenced, promotional decisions

Build a real-time, geofenced promo engine on Harper's agentic runtime. The Nearstore Agent collapses geofence lookup, customer data, campaigns, and AI decisions into a single process. Clone the reference repo and deploy in minutes.
Aleks Haugom
Apr 2026
Blog

The Nearstore Agent: a reference pattern for low-latency, geofenced, promotional decisions

Build a real-time, geofenced promo engine on Harper's agentic runtime. The Nearstore Agent collapses geofence lookup, customer data, campaigns, and AI decisions into a single process. Clone the reference repo and deploy in minutes.
Aleks Haugom
Blog

The Nearstore Agent: a reference pattern for low-latency, geofenced, promotional decisions

Build a real-time, geofenced promo engine on Harper's agentic runtime. The Nearstore Agent collapses geofence lookup, customer data, campaigns, and AI decisions into a single process. Clone the reference repo and deploy in minutes.
Aleks Haugom
Blog
GitHub Logo

How a Shopify Custom Tie Shop Exposes a Common Flaw in Agent Architecture

Explore how a Shopify-based custom tie shop reveals a critical flaw in one LLM agent design strategy, and why context-first architectures with unified runtimes deliver faster, more accurate, and scalable customer support automation.
Blog
Explore how a Shopify-based custom tie shop reveals a critical flaw in one LLM agent design strategy, and why context-first architectures with unified runtimes deliver faster, more accurate, and scalable customer support automation.
Person with short dark hair and moustache, wearing a colorful plaid shirt, smiling outdoors in a forested mountain landscape.
Aleks Haugom
Senior Manager of GTM
Blog

How a Shopify Custom Tie Shop Exposes a Common Flaw in Agent Architecture

Explore how a Shopify-based custom tie shop reveals a critical flaw in one LLM agent design strategy, and why context-first architectures with unified runtimes deliver faster, more accurate, and scalable customer support automation.
Aleks Haugom
Apr 2026
Blog

How a Shopify Custom Tie Shop Exposes a Common Flaw in Agent Architecture

Explore how a Shopify-based custom tie shop reveals a critical flaw in one LLM agent design strategy, and why context-first architectures with unified runtimes deliver faster, more accurate, and scalable customer support automation.
Aleks Haugom
Blog

How a Shopify Custom Tie Shop Exposes a Common Flaw in Agent Architecture

Explore how a Shopify-based custom tie shop reveals a critical flaw in one LLM agent design strategy, and why context-first architectures with unified runtimes deliver faster, more accurate, and scalable customer support automation.
Aleks Haugom
Blog
GitHub Logo

Nobody Wants to Pick a Data Center (And They Shouldn't Have To)

Harper Fabric simplifies cloud deployment by eliminating the need to choose data centers, automating infrastructure, scaling, and global distribution. Built for Harper’s unified runtime, it enables developers to deploy high-performance, distributed applications quickly without managing complex cloud configurations or infrastructure overhead.
Blog
Harper Fabric simplifies cloud deployment by eliminating the need to choose data centers, automating infrastructure, scaling, and global distribution. Built for Harper’s unified runtime, it enables developers to deploy high-performance, distributed applications quickly without managing complex cloud configurations or infrastructure overhead.
Headshot of a smiling woman with shoulder-length dark hair wearing a black sweater with white stripes and a gold pendant necklace, standing outdoors with blurred trees and mountains in the background.
Bari Jay
Senior Director of Product Management
Blog

Nobody Wants to Pick a Data Center (And They Shouldn't Have To)

Harper Fabric simplifies cloud deployment by eliminating the need to choose data centers, automating infrastructure, scaling, and global distribution. Built for Harper’s unified runtime, it enables developers to deploy high-performance, distributed applications quickly without managing complex cloud configurations or infrastructure overhead.
Bari Jay
Apr 2026
Blog

Nobody Wants to Pick a Data Center (And They Shouldn't Have To)

Harper Fabric simplifies cloud deployment by eliminating the need to choose data centers, automating infrastructure, scaling, and global distribution. Built for Harper’s unified runtime, it enables developers to deploy high-performance, distributed applications quickly without managing complex cloud configurations or infrastructure overhead.
Bari Jay
Blog

Nobody Wants to Pick a Data Center (And They Shouldn't Have To)

Harper Fabric simplifies cloud deployment by eliminating the need to choose data centers, automating infrastructure, scaling, and global distribution. Built for Harper’s unified runtime, it enables developers to deploy high-performance, distributed applications quickly without managing complex cloud configurations or infrastructure overhead.
Bari Jay
Blog
GitHub Logo

New RocksDB Binding for Node.js

rocksdb-js is a modern Node.js binding for RocksDB, offering full transaction support, lazy range queries, and a TypeScript API. Built for performance and scalability, it enables reliable write-heavy workloads, real-time replication, and high-concurrency applications in Harper 5.0 and beyond.
Blog
rocksdb-js is a modern Node.js binding for RocksDB, offering full transaction support, lazy range queries, and a TypeScript API. Built for performance and scalability, it enables reliable write-heavy workloads, real-time replication, and high-concurrency applications in Harper 5.0 and beyond.
Person with short hair and rectangular glasses wearing a plaid shirt over a dark T‑shirt, smiling broadly with a blurred outdoor background of trees and hills.
Chris Barber
Staff Software Engineer
Blog

New RocksDB Binding for Node.js

rocksdb-js is a modern Node.js binding for RocksDB, offering full transaction support, lazy range queries, and a TypeScript API. Built for performance and scalability, it enables reliable write-heavy workloads, real-time replication, and high-concurrency applications in Harper 5.0 and beyond.
Chris Barber
Apr 2026
Blog

New RocksDB Binding for Node.js

rocksdb-js is a modern Node.js binding for RocksDB, offering full transaction support, lazy range queries, and a TypeScript API. Built for performance and scalability, it enables reliable write-heavy workloads, real-time replication, and high-concurrency applications in Harper 5.0 and beyond.
Chris Barber
Blog

New RocksDB Binding for Node.js

rocksdb-js is a modern Node.js binding for RocksDB, offering full transaction support, lazy range queries, and a TypeScript API. Built for performance and scalability, it enables reliable write-heavy workloads, real-time replication, and high-concurrency applications in Harper 5.0 and beyond.
Chris Barber
Blog
GitHub Logo

Open Sourcing Harper

Harper is now open source, with its core platform released under Apache 2.0 and enterprise features source-available. This shift builds trust, enables community contributions, and positions Harper as a unified, transparent platform for developers and AI-driven applications.
Blog
Harper is now open source, with its core platform released under Apache 2.0 and enterprise features source-available. This shift builds trust, enables community contributions, and positions Harper as a unified, transparent platform for developers and AI-driven applications.
Person with shoulder‑length curly brown hair and light beard wearing a gray long‑sleeve shirt, smiling outdoors with trees and greenery in the background.
Ethan Arrowood
Senior Software Engineer
Blog

Open Sourcing Harper

Harper is now open source, with its core platform released under Apache 2.0 and enterprise features source-available. This shift builds trust, enables community contributions, and positions Harper as a unified, transparent platform for developers and AI-driven applications.
Ethan Arrowood
Apr 2026
Blog

Open Sourcing Harper

Harper is now open source, with its core platform released under Apache 2.0 and enterprise features source-available. This shift builds trust, enables community contributions, and positions Harper as a unified, transparent platform for developers and AI-driven applications.
Ethan Arrowood
Blog

Open Sourcing Harper

Harper is now open source, with its core platform released under Apache 2.0 and enterprise features source-available. This shift builds trust, enables community contributions, and positions Harper as a unified, transparent platform for developers and AI-driven applications.
Ethan Arrowood