RTMP.Limits (rtmp v0.1.0)

Copy Markdown View Source

Per-connection hard limits.

Every limit exists to keep a broken or hostile peer from making the server use unbounded memory or hold a connection open forever. When a limit is hit the connection is closed with {:protocol_error, reason} and the listener is unaffected.

OptionDefaultWhat it bounds
:max_chunk_size1 MiB (1_048_576)The largest chunk size a peer may set with Set Chunk Size.
:max_message_size8 MiB (8_388_608)The largest single message (e.g. one video keyframe) a peer may declare.
:max_chunk_streams16Distinct chunk stream IDs tracked per connection. Real encoders use fewer than 8.
:max_buffered_bytes16 MiB (16_777_216)Total bytes held in partially received messages across all chunk streams of one connection.
:idle_timeout30_000 msClose the connection if no bytes arrive for this long after the handshake.
:handshake_timeout10_000 msClose the connection if any single handshake step takes longer than this.

The worst-case memory a single connection can hold in reassembly buffers is therefore max_buffered_bytes (plus at most one chunk of unparsed input), regardless of what the peer sends.

Summary

Functions

Builds limits from a keyword list (or returns an existing struct as is).

Types

t()

@type t() :: %RTMP.Limits{
  handshake_timeout: pos_integer(),
  idle_timeout: pos_integer(),
  max_buffered_bytes: pos_integer(),
  max_chunk_size: pos_integer(),
  max_chunk_streams: pos_integer(),
  max_message_size: pos_integer()
}

Functions

new(limits)

@spec new(t() | keyword()) :: t()

Builds limits from a keyword list (or returns an existing struct as is).

Raises ArgumentError on unknown keys or values that aren't positive integers — this is configuration, checked once at startup.