MIDI Relay

2026Real-time / Networked

WebSocket relay forwarding MIDI bytes between remote clients without inbound ports. Sub-50ms latency for networked installations.

MIDI Relay exists because two musicians on different networks can't just open a port to each other. Both sender and receiver dial out to the relay, so neither end touches a firewall — the relay is the only machine on the public internet. Built for remote robotic instrument control with the jazz band Speaker's Corner Quartet.

How it works

  • Control messages travel as JSON; the MIDI itself is forwarded as raw binary frames, untouched. The server is a transparent byte pipe — it never parses MIDI, so all protocol logic lives at the edges.
  • One runtime dependency (ws). Rooms auto-create on join and auto-delete when empty; there are no accounts and no session state.
  • Three layers of in-memory rate limiting. Excess messages are dropped silently instead of disconnecting the client, so a MIDI-clock burst at 24 pulses per quarter note doesn't kill the connection that sent it.
  • The browser client reconnects with exponential backoff (1 s → 30 s cap) and speaks the Web MIDI API directly, sysex included.
  • An optional Arduino receiver bridges the relay to a physical serial port — internet MIDI that ends at a microcontroller, with independent reconnect logic on both the socket and the serial link.

Numbers

68 tests. The relay adds 0.33 ms on average (measured locally). Stress test: 5 senders × 5 receivers at 48 messages per second each, with one sender killed mid-run — zero messages dropped.

Deployed behind Nginx in Docker, with systemd and PM2 configs for the paranoid.

Node.jsWebSocketsWeb MIDINginxDocker
Live ↗GitHub
websocketsmidirealtimeinfrastructure