Real-time publisher and subscriber clients for Harper using MQTT, WebSocket, and Server-Sent Events (SSE).
- Python 3.7+
- paho-mqtt package (v2.0.0+) - for MQTT clients
- websockets package (v12.0+) - for WebSocket clients
- sseclient-py package (v1.8.0+) - for SSE clients
- requests package (v2.31.0+) - for SSE clients
pip install -r requirements.txtOr install directly:
pip install paho-mqtt websockets sseclient-py requests./mqtt-publish.py
# or
python3 mqtt-publish.py./mqtt-subscribe.py
# or
python3 mqtt-subscribe.py./ws-publish.py
# or
python3 ws-publish.py./ws-subscribe.py
# or
python3 ws-subscribe.py./sse-subscribe.py
# or
python3 sse-subscribe.pyNote: SSE is unidirectional (server to client only), so there is no SSE publisher.
All clients follow the same tier progression:
- Tier 0 (MVP): Single publish, automatic database persistence for WebSocket/SSE
- Tier 1: Database persistence enabled (MQTT:
retain=True) - Tier 2: Continuous publishing every 5 seconds
- MQTT: Full pub/sub broker, topic-based routing, QoS levels
- WebSocket: Bidirectional, direct resource connection, lower overhead
- SSE: Unidirectional (server→client), simple HTTP-based, automatic reconnection