Overview
The MQTT relay enables hcom instances on different machines to communicate. Messages, events, and state sync in real-time across devices. Use cases:- Work on desktop, monitor from laptop
- Share agents between team members
- Run heavy workloads on remote server, control from local machine
- Multi-device development workflows
Quick Setup
Create a Relay Group
On your first device:Join from Other Devices
On your second device:Verify Connection
How It Works
Architecture
- Each device runs a relay daemon that connects to the MQTT broker
- When an event occurs (message, status change, agent lifecycle), the local daemon publishes to MQTT
- Remote daemons receive the event and insert it into their local database
- Agents on all devices see the same unified event stream
What Gets Synced
Synced:- Messages (
hcom send) - Agent status (active, listening, blocked, stopped)
- Lifecycle events (created, started, stopped)
- File edits
- Command execution
- Event subscriptions
- Transcripts (stored locally)
- File contents (only edit notifications)
- Agent processes (each device runs its own agents)
Public vs Private Brokers
Public Brokers (Default)
hcom tries these public MQTT brokers in order:broker.emqx.io:1883broker.hivemq.com:1883test.mosquitto.org:1883
- No setup required
- Free
- No hosting needed
- Messages are encrypted but pass through public infrastructure
- Relies on third-party availability
- Subject to broker rate limits
Private Broker (Recommended for Teams)
Run your own MQTT broker for full control:/etc/mosquitto/mosquitto.conf):
TLS/SSL (Secure)
For production, use encrypted connection:Managing the Relay
Enable/Disable Sync
Daemon Control
hcom relay connect or hcom relay new.
Remove Relay Configuration
Edit~/.hcom/config.toml and remove the [relay] section:
Remote Agent Naming
Agents on remote devices are namespaced by device:Addressing Remote Agents
List Remote Agents
Troubleshooting
Daemon Won’t Start
Check if already running:Connection Failed
Test broker connectivity:Messages Not Syncing
Verify relay is enabled:High Latency
Use a private broker closer to your devices:Security Considerations
Token Security
The relay token contains:- Relay group ID (UUID)
- Broker URL
- Don’t share tokens publicly
- Rotate tokens by creating a new relay group
- Use a private broker for sensitive work
Message Encryption
hcom does not encrypt message content. MQTT transmits messages as plaintext unless you use:- TLS/SSL (
mqtts://) for transport encryption - Private broker on your own network
- Use a private broker with TLS
- Or use a VPN/SSH tunnel to the broker
- Or implement application-level encryption (future feature)
Advanced Configuration
Custom Device ID
Device IDs are auto-generated (6 characters, e.g.,LAPTOP). To customize:
Edit ~/.hcom/relay.device (create if missing):
Relay with HCOM_DIR (Sandbox Mode)
Each HCOM_DIR can have its own relay configuration:Performance
Bandwidth Usage
Typical message sizes:- Text message: ~500 bytes
- Status update: ~200 bytes
- File edit event: ~300 bytes
- 100 messages/day ≈ 50 KB/day
- 1000 messages/day ≈ 500 KB/day
Scaling
Public brokers rate-limit connections. For large teams:- Run a private broker (Mosquitto, EMQX, HiveMQ)
- Use dedicated relay group per team (separate tokens)
- Monitor broker metrics (connections, message rate)