PhoenixWebTransport (phoenix_wtransport v0.1.0)

Copy Markdown View Source

WebTransport (HTTP/3 over QUIC) as a transport for Phoenix sockets and LiveView, with one QUIC stream per LiveView component and shortest-message-first scheduling.

Add {PhoenixWebTransport, endpoint: MyAppWeb.Endpoint} (or PhoenixWebTransport.Supervisor / PhoenixWebTransport.Quic.Listener) to your supervision tree next to the endpoint:

  • Pure-Erlang QUIC + HTTP/3 on benoitc/erlang_quic (zero native builds)
  • Optional socket_backend: :socket for OTP socket NIF (GRO/GSO on Linux)

Listeners register here (unless register: false), so pages and PhoenixWebTransport.Plug can read url/0, port/0, and cert_hash/0.

Summary

Functions

Hex SHA-256 of the served dev cert for serverCertificateHashes, or nil.

Child specification delegating to PhoenixWebTransport.Supervisor.

Whether a WebTransport listener is running in this VM.

Returns QUIC path metrics (srtt, cwnd, congested, etc.) for a session.

The UDP port of the registered WebTransport listener, or nil.

Sends an opt-in RFC 9297 unreliable datagram (with automatic lane-0 fallback).

Returns runtime diagnostics for a live WebTransport session process.

Switches congestion control (:bbr | :cubic | :newreno) on a live session.

Sets an opt-in send deadline (timeout_ms) on a lane or slot.

Starts PhoenixWebTransport.Supervisor with the given options.

The URL pages should hand to LiveSocket, or nil when no listener runs.

Functions

cert_hash()

@spec cert_hash() :: String.t() | nil

Hex SHA-256 of the served dev cert for serverCertificateHashes, or nil.

child_spec(opts)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Child specification delegating to PhoenixWebTransport.Supervisor.

enabled?()

@spec enabled?() :: boolean()

Whether a WebTransport listener is running in this VM.

path_stats(session)

@spec path_stats(GenServer.server()) :: {:ok, map()} | {:error, term()}

Returns QUIC path metrics (srtt, cwnd, congested, etc.) for a session.

port()

@spec port() :: :inet.port_number() | nil

The UDP port of the registered WebTransport listener, or nil.

send_datagram(session, payload, opts \\ [])

@spec send_datagram(GenServer.server(), iodata(), keyword()) :: :ok

Sends an opt-in RFC 9297 unreliable datagram (with automatic lane-0 fallback).

session_info(session)

@spec session_info(GenServer.server()) :: {:ok, map()} | {:error, term()}

Returns runtime diagnostics for a live WebTransport session process.

set_congestion_control(session, algorithm)

@spec set_congestion_control(GenServer.server(), :bbr | :cubic | :newreno) ::
  :ok | {:error, term()}

Switches congestion control (:bbr | :cubic | :newreno) on a live session.

set_stream_deadline(session, lane_or_slot, timeout_ms, opts \\ [])

@spec set_stream_deadline(
  GenServer.server(),
  non_neg_integer(),
  pos_integer(),
  keyword()
) ::
  :ok | {:error, term()}

Sets an opt-in send deadline (timeout_ms) on a lane or slot.

start_link(opts)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts PhoenixWebTransport.Supervisor with the given options.

url()

@spec url() :: String.t() | nil

The URL pages should hand to LiveSocket, or nil when no listener runs.