Skip to content

Architecture & Failover ​

Connekt uses a star-topology Rust Hub (connekt-core / connekt-hub) that abstracts away transport mechanics and exposes one unified peer registry across USB and LAN.

Connekt Multi-App Hub System ArchitectureConnekt Multi-App Hub System Architecture

Core Design Principles ​

Multi-App Safe per Physical Device ​

Every connected app identifies itself with a stable peer_id composed of its persistent device fingerprint and bundle/package identifier (<device_hash>/<app_package>). Multiple apps on the same Android or iOS device — and multiple browser tabs — connect side-by-side over the same physical link without port collisions or crosstalk.

Each peer can maintain multiple simultaneous transports inside PeerRegistry. The Hub ranks transports by deterministic priority:

TransportPriorityMechanism
adb100Android USB via adb reverse tcp:19527
usbmux100iOS USB via usbmuxd loopback listener
lan50LAN WebSocket (/ws) discovered via UDP broadcast or Bonjour (_connekt._tcp)
custom25User-supplied custom Transport adapter
relay10Future authenticated WAN WebSocket relay

When a device is reachable over both USB and LAN:

  1. Both connections merge under a single peer_id (never duplicated as two peers).
  2. Outbound traffic routes over the highest-priority active transport (USB, priority 100).
  3. The LAN link stays warm in HOT_STANDBY mode.

USB → Wi-Fi Hot-Standby Failover ​

Connekt USB to LAN Wi-Fi Hot-Standby Failover AnimationConnekt USB to LAN Wi-Fi Hot-Standby Failover Animation
  1. While tethered, messages, RPCs, and binary streams travel over USB (ADB reverse / usbmuxd).
  2. The moment the USB cable is unplugged, PeerRegistry removes the dead USB link and immediately promotes the standby LAN WebSocket to active_transport.
  3. When the cable is plugged back in, USB reconnects automatically and reclaims priority 100 seamlessly.

iOS Privacy-First LAN Default

Both Android and iOS keep enableLan = false by default. This guarantees that pure USB debugging sessions on iOS never trigger Apple's "Local Network" permission prompt unless your app explicitly opts into wireless failover (enableLan = true).

Zero-Copy Routing & Stream Multiplexing ​

  • Multicast fan-out: Sending to [peerA, peerB] or "*" wraps the payload once in bytes::Bytes (reference-counted) and fans out across target queues with zero buffer copies.
  • 0-RTT Binary Streams: STREAM_OPEN carries optional JSON metadata (meta), while every STREAM_DATA chunk carries zero JSON overhead (only the fixed 19-byte CK v1 binary header + raw chunk bytes).
  • Early Reject & Cancel: Receivers inspect stream.meta immediately on onStream and can call reject(reason) before reading a single byte, tearing down the stream on the sender cleanly.

See Wire Protocol (CK v1) for exact binary framing details.

Released under the MIT License.