Short answer: treat a heartbeat as evidence of recent contact, never as proof that every incident event reached every dashboard; for marketplace device status, use an ordered event stream with per-device sequence numbers, resumable cursors, and idempotent projection, while reserving WebRTC for sessions whose latency and peer-to-peer topology justify its operational cost.

That separation matters during incident response. A green pulse can arrive after an alarm was dropped, and a red pulse can reflect a sleeping radio rather than a broken device. The dashboard therefore needs two independently auditable statements: when the service last heard from the device, and through which event each viewer has advanced.

No single transport creates exactly-once delivery.

What should a realtime heartbeat monitoring dashboard guarantee during incident response?

The useful contract has three layers. First, liveness is a lease: a device is online only until a server-calculated deadline, and a late heartbeat renews the lease without rewriting history. Second, incident events form a device-scoped ordered log. Third, each dashboard projection records the highest contiguous sequence it has applied. This produces a precise answer to the awkward operator question: "Did the warning disappear, or did this browser never receive it?"

For example, suppose device seller-kiosk-042 emits sequences 1842, 1843, and 1844, but a browser receives 1842 and 1844. Rendering 1844 immediately may look fast, yet it hides an unknown transition. The projection should mark a gap, request replay from 1843, and apply the recovered records through the same idempotent path. If 1843 later arrives twice, its stable event ID makes the second application a no-op. The audit record retains receipt time, device time, sequence, event ID, and the projection cursor; it does not pretend that transport receipt and business processing are one atomic act.

This is the exactly-once mindset in its defensible form: at-least-once movement, deterministic deduplication, contiguous advancement, and evidence that can be reconciled. "Exactly once" as a transport label is too weak for an incident ledger because it says nothing about a process crash between receiving a message and committing the visible state.

The contract must also admit uncertainty. Clock skew makes a device timestamp unsuitable as the sole ordering key, while reconnects can make arrival time misleading. A monotonic sequence allocated within a device epoch avoids both traps; if a factory reset can reuse numbers, add an epoch identifier and make (device_id, epoch, sequence) unique. I'm not sure one expiry interval fits every device class, because radio duty cycles and operational severity differ; production evidence from each class should set the lease and alert thresholds.

Heartbeats and events need separate state machines

A heartbeat can be lossy by design. If the server receives the newest heartbeat, replaying three older pulses adds load without improving the current liveness estimate. An alarm transition is different: missing temperature_normal after temperature_high, or applying those transitions in reverse, can leave an incident open or close it incorrectly.

Keep both paths explicit:

Signal Durable? Ordering rule Dashboard behavior
Heartbeat Usually no Newest accepted observation wins Recompute lease expiry
Status transition Yes Contiguous sequence within device epoch Apply once, replay gaps
Operator action Yes Server-assigned audit order plus idempotency key Commit before acknowledgment
Ephemeral presence No Best effort Replace, do not replay

The distinction also prevents fan-out pressure from corrupting ingestion. Device writes should terminate at an authenticated ingress, which validates identity and appends durable transitions before any browser delivery. A separate projection reads that log, updates current status transactionally, and publishes a compact envelope to connected dashboard nodes. Slow browsers consume bounded queues; when a queue reaches its limit, the node disconnects the client with a resumable cursor instead of retaining unbounded memory or silently skipping durable events.

Short path, hard boundary.

Compliance follows the data rather than the transport name. Heartbeats often reveal location, working patterns, or merchant activity, so retention should be shorter than incident-history retention when the audit purpose permits it. Access decisions belong at subscription time and replay time. A tenant-scoped cursor must never authorize a broader replay merely because the browser still possesses it, and audit logs should record which principal requested which device range without copying sensitive payloads into general application logs.

Choosing WebRTC, WebSocket, SSE, or polling by fan-out behavior

WebRTC data channels can carry arbitrary application data between peers. The W3C API exposes ordered delivery and limited-retransmission controls through RTCDataChannel, while the underlying peer connection includes ICE negotiation and connection state. Those controls are useful, but they do not replace application sequence numbers, durable replay, authorization, or an audit trail. An ordered channel orders what that channel delivers; it cannot prove that a marketplace incident was durably committed before a viewer saw it.

For a server-originated dashboard with many viewers, WebSocket and Server-Sent Events usually fit the topology more directly: the service remains the authority and each browser maintains a server connection. WebSocket supports bidirectional messages. SSE suits predominantly server-to-browser updates and browser-native reconnection. Polling is operationally plain and can be an acceptable fallback when update frequency is low or intermediaries make long-lived connections unreliable. These are protocol-shape observations, not a ranking.

WebRTC becomes a stronger candidate when devices or operators genuinely need peer-to-peer media or data, when a direct path materially changes interaction latency, or when the same session already carries audio or video. The catch is signaling, ICE traversal, peer lifecycle, and per-peer fan-out: for a dashboard broadcasting one authoritative status stream to hundreds of viewers, those concerns can outweigh the latency benefit. Stick with a server-centric stream when durable replay and centralized authorization dominate; use polling when simplicity matters more than sub-second presentation.

The comparison must be made under disconnect, not on a clean local network. Measure reconnection storms, queue saturation, replay duration, duplicate rate, gap frequency, and the age of the oldest unprojected event. Tail latency matters more than a flattering median during a regional incident because every dashboard reconnecting at once is the real workload. Your mileage may vary -- especially on mobile networks -- so record results by network class and connection age.

A Go projection that makes gaps visible

The projection below is deliberately transport-neutral. A WebRTC data channel, WebSocket handler, SSE subscriber, or polling endpoint can all feed the same Apply method after authentication. The important part is that delivery mechanics do not get to weaken state correctness.

package status import ( "context" "errors" "fmt" ) var ErrGap = errors.New("non-contiguous device sequence") type Event struct { ID string DeviceID string Epoch string Sequence uint64 Kind string } type Store interface { // Transaction must atomically check the event ID, update status, and advance the cursor. Transaction(ctx context.Context, event Event, apply func() error) (duplicate bool, err error) Cursor(ctx context.Context, deviceID, epoch string) (uint64, error) SetStatus(ctx context.Context, deviceID, kind string) error } type Projector struct { store Store } func (p Projector) Apply(ctx context.Context, event Event) error { current, err := p.store.Cursor(ctx, event.DeviceID, event.Epoch) if err != nil { return fmt.Errorf("read cursor: %w", err) } if event.Sequence <= current { return nil // A replay is expected and harmless. } if event.Sequence != current+1 { return fmt.Errorf("%w: have=%d received=%d", ErrGap, current, event.Sequence) } _, err = p.store.Transaction(ctx, event, func() error { return p.store.SetStatus(ctx, event.DeviceID, event.Kind) }) if err != nil { return fmt.Errorf("apply event %s: %w", event.ID, err) } return nil } 

The interface leaves one critical obligation to the store implementation: deduplication, status mutation, and cursor advancement share a transaction. A handler acknowledges only after that transaction commits. On ErrGap, it asks the durable log for the missing inclusive range and pauses later transitions for that device; other devices continue, which prevents one offline kiosk from creating head-of-line blocking across the marketplace.

Test this with histories, not isolated messages. Generate duplicates, reorder adjacent sequences, restart the projector immediately before and after commit, expire a heartbeat while events continue, and reconnect thousands of synthetic viewers from old cursors. The invariants are crisp: a committed event changes the projection at most once, a cursor never jumps across a gap, a viewer can rebuild from a retained cursor, and liveness expiry never deletes incident history.

How can teams roll out a delivery contract before changing transport?

Start by adding event IDs, epochs, and sequences to the existing path while dashboards remain unchanged. Run the new projector in shadow mode, compare its state against the current read model, and investigate every mismatch as a reconciliation item. Next, expose cursor-based replay to a small internal audience, then force disconnects and verify that their views converge without manual refresh. Only after the invariants hold should traffic move between polling, a server stream, or WebRTC.

Keep rollback asymmetric: switching the live transport back must not discard the durable log or its cursors. That makes presentation reversible while preserving the evidence needed to explain an incident. It also keeps the decision honest. A team can adopt the simplest transport that meets measured latency and fan-out targets, then change it later without changing the status ledger.

References