Industrial Protocol Bridge - Modbus TCP/RTU to JSON/MQTT Gateway
RustBridge is a high-performance, lightweight gateway that bridges industrial Modbus devices to modern IoT infrastructure. Built with Rust for reliability, speed, and minimal resource usage.
π "Connecting legacy PLCs to the cloud, one register at a time."
Try the API without installing anything:
# Health check
curl https://rustbridge.mustafasarac.com/health
# API info
curl https://rustbridge.mustafasarac.com/api/info
# Prometheus metrics
curl https://rustbridge.mustafasarac.com/metricsDemo URL: rustbridge.mustafasarac.com
- π High Performance β Handles 1000+ registers per second
- π Dual Protocol β Modbus TCP and RTU (serial) support
- π‘ MQTT Publisher β Real-time data streaming to any MQTT broker
- π REST API β JSON endpoints for integration
- π WebSocket β Real-time updates for dashboards
- π Prometheus Metrics β Production-ready monitoring
- π³ Docker Ready β Single command deployment
- β‘ Edge Optimized β Runs on Raspberry Pi, industrial gateways
| Document | Description |
|---|---|
| Getting Started | Quick installation and first steps |
| Configuration | Complete configuration reference |
| API Reference | REST API and WebSocket documentation |
| Modbus Guide | Modbus protocol deep dive |
| MQTT Integration | MQTT broker setup and topics |
| Prometheus Metrics | Monitoring and alerting |
| Deployment | Production deployment strategies |
| Troubleshooting | Common issues and solutions |
| Examples | Real-world use cases |
# Simple run
docker run -d \
-p 3000:3000 \
-v ./config.yaml:/app/config.yaml \
ghcr.io/neurabytelabs/rustbridge:latest
# With Docker Compose (includes MQTT broker)
docker compose up -dDownload the latest release for your platform from GitHub Releases:
- Linux x86_64:
rustbridge-x86_64-unknown-linux-gnu - Linux ARM64:
rustbridge-aarch64-unknown-linux-gnu - macOS Intel:
rustbridge-x86_64-apple-darwin - macOS Apple Silicon:
rustbridge-aarch64-apple-darwin
chmod +x rustbridge-*
./rustbridge-x86_64-unknown-linux-gnugit clone https://github.com/neurabytelabs/rustbridge.git
cd rustbridge
cargo build --release
./target/release/rustbridgeCreate a config.yaml file:
server:
host: "0.0.0.0"
port: 3000
metrics_enabled: true
mqtt:
enabled: true
host: "localhost"
port: 1883
client_id: "rustbridge"
topic_prefix: "rustbridge"
qos: 1
retain: false
# API Authentication (optional)
auth:
enabled: true
api_keys:
- "your-secret-key-1"
- "your-secret-key-2"
exclude_paths:
- "/health"
- "/metrics"
devices:
# Modbus TCP device
- id: "plc-01"
name: "Main PLC"
device_type: tcp
connection:
host: "192.168.1.100"
port: 502
unit_id: 1
poll_interval_ms: 1000
registers:
- name: "temperature"
address: 0
register_type: holding
count: 1
data_type: u16
unit: "Β°C"
scale: 0.1
# Modbus RTU (Serial) device
- id: "sensor-01"
name: "RTU Sensor"
device_type: rtu
connection:
port: "/dev/ttyUSB0"
baud_rate: 9600
data_bits: 8
stop_bits: 1
parity: "none"
unit_id: 1
poll_interval_ms: 2000
registers:
- name: "humidity"
address: 0
register_type: input
count: 1
data_type: u16
unit: "%"π See Configuration Reference for all options.
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/metrics |
GET | Prometheus metrics |
/api/info |
GET | API information |
/api/devices |
GET | List all devices |
/api/devices/:id |
GET | Get device details |
/api/devices/:id/registers |
GET | Get all register values |
/api/devices/:id/registers/:name |
GET/POST | Get/Write register |
/ws |
WebSocket | Real-time updates |
{
"name": "temperature",
"value": 72.4,
"raw": [724],
"unit": "Β°C",
"timestamp": "2025-12-26T23:15:00Z"
}π See API Reference for full documentation.
Data is published to: {prefix}/{device_id}/{register_name}
Example: rustbridge/plc-01/temperature
{
"value": 72.4,
"raw": [724],
"unit": "Β°C",
"timestamp": "2025-12-26T23:15:00Z"
}π See MQTT Integration for broker setup.
Available at /metrics when metrics_enabled: true:
| Metric | Type | Description |
|---|---|---|
rustbridge_register_reads_total |
Counter | Total register read attempts |
rustbridge_read_duration_seconds |
Histogram | Read latency distribution |
rustbridge_register_value |
Gauge | Current register values |
rustbridge_errors_total |
Counter | Error count by type |
rustbridge_device_connected |
Gauge | Device connection status |
rustbridge_poll_cycle_seconds |
Histogram | Poll cycle duration |
π See Prometheus Metrics for Grafana dashboards and alerting.
# Production stack
docker compose up -d
# With monitoring (Prometheus + Grafana)
docker compose --profile monitoring up -d
# With Modbus simulator for testing
docker compose --profile dev up -dAccess:
- RustBridge API: http://localhost:3000
- Prometheus: http://localhost:9090 (with monitoring profile)
- Grafana: http://localhost:3001 (admin/rustbridge)
# Install
cd deploy
sudo ./install.sh
# Control
sudo systemctl start rustbridge
sudo systemctl status rustbridge
sudo journalctl -u rustbridge -f# Coming soon - Helm chart
helm repo add rustbridge https://neurabytelabs.github.io/rustbridge
helm install rustbridge rustbridge/rustbridgeπ See Deployment Guide for HA setup, edge devices, and more.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RUSTBRIDGE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββ ββββββββββββ ββββββββββ βββββββββββ β
β β Modbus βββββΆβ Polling βββββΆβBroadcastββββΆβ MQTT β β
β βTCP/RTU β β Engine β β Channel β βPublisherβ β
β βββββββββββ ββββββββββββ ββββββββββ βββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββ β
β β REST API + WS β β
β β (/api, /ws, /metrics) β β
β ββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββ β
β β Prometheus + Grafana β β
β ββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo run
# Build release
cargo build --release
# Run clippy
cargo clippy
# Format code
cargo fmtrustbridge/
βββ docs/ # π Documentation
β βββ getting-started.md
β βββ configuration.md
β βββ api-reference.md
β βββ modbus-guide.md
β βββ mqtt-integration.md
β βββ prometheus-metrics.md
β βββ deployment.md
β βββ troubleshooting.md
β βββ examples.md
βββ src/
β βββ main.rs # Entry point
β βββ lib.rs # Library exports
β βββ config.rs # Configuration parsing
β βββ bridge.rs # Main orchestration
β βββ api/ # REST API + WebSocket
β βββ modbus/ # Modbus TCP/RTU client
β βββ mqtt/ # MQTT publisher
β βββ metrics/ # Prometheus metrics
βββ deploy/
β βββ mosquitto/ # MQTT broker config
β βββ prometheus/ # Prometheus config
β βββ grafana/ # Grafana provisioning
β βββ systemd/ # systemd service file
β βββ install.sh # Installation script
β βββ uninstall.sh # Uninstallation script
βββ config.yaml # Example configuration
βββ Dockerfile # Multi-stage build
βββ docker-compose.yml # Full stack deployment
- π API Key Authentication β Secure endpoints with
X-API-Keyheader - Non-root Docker container
- systemd security hardening
- TLS support for MQTT connections
- Rate limiting (coming soon)
Enable API key authentication in your config.yaml:
auth:
enabled: true
api_keys:
- "your-secret-api-key"
exclude_paths:
- "/health"
- "/metrics"Then include the key in requests:
curl -H "X-API-Key: your-secret-api-key" https://rustbridge.example.com/api/devicesπ See API Reference for authentication details.
MIT License - See LICENSE for details.
Contributions are welcome! Please read our contributing guidelines.
- GitHub Issues: github.com/neurabytelabs/rustbridge/issues
- Email: mrsarac@gmail.com
Built with β€οΈ by NeuraByte Labs
Part of the Conatus Protocol - Industrial Edge AI Initiative