Data Connections

Dedicated data tunnels for forwarding traffic.

Overview

Data connections carry the actual traffic between public users and local services. Each incoming TCP connection, or UDP datagram session, gets a dedicated data tunnel through port 9001 on the relay server.

Per-connection model

Exposr uses a per-connection data tunnel model. This means:

  • Each public connection gets a unique UUID
  • A fresh TCP connection to port 9001 is created for each public connection
  • The data connection is identified by the UUID
  • When the public client disconnects, or the UDP session ends, the corresponding data connection is closed

This model is simple and reliable but introduces overhead because a new TCP handshake is required for every public connection. Connection pooling is a planned improvement.

Connection flow

  1. Server receives a public TCP connection or UDP datagram and generates a UUID
  2. Server sends CONNECT <uuid> to the agent over the control channel
  3. Agent connects to the local service on the target port
  4. Agent opens a new TCP connection to port 9001
  5. Agent sends DATA <uuid> to identify the connection
  6. Server matches the UUID and bridges the public socket with the data connection
  7. TCP traffic flows as a stream; UDP payloads use length-prefixed frames over the TCP data connection
text
# Agent -> Server (on port 9001):
DATA 8bab2f9a-b0e2-4db2-8fed-9a8dda8e3aed