The Problem: Real-Time Router Fleet Monitoring Without WebSocket Overhead
When integrating gnacho/netpulse into our multi-tenant infrastructure monitoring stack, we needed a lightweight mechanism to stream router health metrics (CPU, memory, WireGuard peer status, AdGuard Home block counts) to browser dashboards without the complexity of WebSocket handshakes or bidirectional chat protocols.
Server-Sent Events (SSE) emerged as the natural fit: unidirectional push over plain HTTP, browser-native EventSource API, automatic reconnection logic. But production deployment revealed three critical failure modes that FastAPI's documentation glosses over.
Architecture Context
The netpulse backend exposes a /events endpoint that aggregates telemetry from multiple OpenWrt routers via their ubus JSON-RPC interface. Each client dashboard maintains a persistent SSE connection, receiving JSON payloads every 5 seconds:
from fastapi import FastAPI from fastapi .…