Skip to content

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.

The proxy operates as a fan-out service:

Upstream 1 ─┐
Upstream 2 ─┤→ websocket-proxy ─→ Client A
Upstream N ─┘ ─→ Client B
─→ Client N

It 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.

FeatureDescription
Fan-outMultiplexes messages from upstream sources to all connected clients
Brotli compressionCompresses WebSocket frames for bandwidth-efficient delivery
API key authAuthenticates clients via API keys before allowing connections
Per-IP rate limitingPrevents abuse by limiting connection rates per source IP
MetricsExposes Prometheus metrics on port 9000
Multiple upstreamsConnects to multiple upstream URIs for redundancy
PortProtocolPurpose
8545WebSocketClient-facing flashblock stream
9000HTTPPrometheus metrics
  • websocket-proxy — Core proxy logic
  • brotli — Brotli compression
  • futures — Async stream utilities
  • hostname — Hostname resolution
  • tokio — Async runtime
Terminal window
# Build the image
docker build -t websocket-proxy -f etc/docker/Dockerfile.websocket-proxy .
# Run
docker run -it --rm \
-p 8545:8545 \
-p 9000:9000 \
websocket-proxy [OPTIONS]
Terminal window
cargo build --bin websocket-proxy --release
Terminal window
./target/release/websocket-proxy [OPTIONS]