websocket-proxy
websocket-proxy fans out flashblock streams from one or more upstream builders to connected clients. It handles Brotli compression, API key authentication, and per-IP rate limiting.
Package
Section titled “Package”- Crate name:
websocket-proxy-bin - Binary name:
websocket-proxy - Source:
bin/websocket-proxy - Library:
crates/infra/websocket-proxy - Dockerfile:
etc/docker/Dockerfile.websocket-proxy
Architecture
Section titled “Architecture”The proxy operates as a fan-out service:
Upstream 1 ─┐Upstream 2 ─┤→ websocket-proxy ─→ Client AUpstream N ─┘ ─→ Client B ─→ Client NIt connects to one or more upstream WebSocket URIs (e.g., builder nodes producing flashblocks) and fans out the messages to all connected downstream clients. This enables horizontal scaling of flashblock delivery.
Features
Section titled “Features”| Feature | Description |
|---|---|
| Fan-out | Multiplexes messages from upstream sources to all connected clients |
| Brotli compression | Compresses WebSocket frames for bandwidth-efficient delivery |
| API key auth | Authenticates clients via API keys before allowing connections |
| Per-IP rate limiting | Prevents abuse by limiting connection rates per source IP |
| Metrics | Exposes Prometheus metrics on port 9000 |
| Multiple upstreams | Connects to multiple upstream URIs for redundancy |
| Port | Protocol | Purpose |
|---|---|---|
| 8545 | WebSocket | Client-facing flashblock stream |
| 9000 | HTTP | Prometheus metrics |
Key Dependencies
Section titled “Key Dependencies”websocket-proxy— Core proxy logicbrotli— Brotli compressionfutures— Async stream utilitieshostname— Hostname resolutiontokio— Async runtime
Docker
Section titled “Docker”# Build the imagedocker build -t websocket-proxy -f etc/docker/Dockerfile.websocket-proxy .
# Rundocker run -it --rm \ -p 8545:8545 \ -p 9000:9000 \ websocket-proxy [OPTIONS]cargo build --bin websocket-proxy --release./target/release/websocket-proxy [OPTIONS]