Skip to content

Limits and timeouts

etemenanki-app bounds every stage of a connection: how long a client may take to authenticate, how long a relay may sit idle, how many connections one listener holds, how large a message may be. Most of these values are fixed in the code and sized well above normal traffic. A few belong to one protocol and are settings.

Read this page when a connection closes and you want to know which timer closed it, when you size a server, or when you need to know whether UDP gets through a particular inbound and outbound. Each section says what happens at the limit and what the log shows.

Twenty-four keys change a limit. They all belong to one protocol, or to a balancer, and each is described in full on that page. Every other value on this page is fixed.

Key Where Default Accepted values
max_connections hysteria2 inbound settings 262144 1 or more
max_circuits hysteria2 inbound settings 4194304 1 or more
udp_idle_timeout hysteria2 inbound settings 60 (seconds) 2 to 600, and only with udp = true
max_concurrent_streams hysteria2 outbound settings 102400 1 or more
quic.max_stream_receive_window hysteria2 settings, both sides 8388608 (bytes) 16384 or more
quic.max_conn_receive_window hysteria2 settings, both sides 20971520 (bytes) 16384 or more
quic.max_idle_timeout hysteria2 settings, both sides 30 (seconds) 4 to 120
quic.keep_alive_period hysteria2 outbound settings 10 (seconds) 2 to 60
quic.max_incoming_streams hysteria2 inbound settings 65536 1 or more
hop_interval hysteria2 outbound settings 30 (seconds) 5 or more, with ports
mtu tun inbound settings 1500 1280 to 65535
udp_idle_timeout tun inbound settings 60 (seconds) whole seconds
max_flows tun inbound settings 65536 a whole number
mtu wireguard outbound settings 1420 whole bytes; see below
keepalive wireguard outbound settings unset (off) 0 to 65535 seconds; 0 is off
header_timeout sss inbound settings "10s" a duration with its unit, above zero
udp_max_datagram sss settings, both sides 65535 (bytes) 1 to 65535, the same on both ends
flush_delay sss settings, both sides "0ms" a duration with its unit, at most "10ms"
idle_session_check_interval anytls outbound settings 30 (seconds) whole seconds; 5 or less means 30
idle_session_timeout anytls outbound settings 30 (seconds) whole seconds; 5 or less means 30
min_idle_session anytls outbound settings 0 a whole number of idle sessions to keep
reality.max_time_diff vless inbound with REALITY unset (no check) whole seconds; 0 is no check
probe_interval [[balancer]] 30 (seconds) whole seconds
probe_timeout [[balancer]] 5 (seconds) whole seconds

All of them except sss’s two durations are plain integers. Their durations are whole seconds, so probe_interval = "30s" is a parse error at that line, not 30 seconds:

configuration invalid: TOML parse error at line 8, column 18

sss’s header_timeout and flush_delay are the other way round: a string with its unit, s or ms, such as "10s" or "5ms". A bare number there fails with inbound sss-in: invalid settings: invalid type: integer `10`, expected a string.

A value outside the integer type is a parse error too, for example mtu = 70000 on a TUN inbound: inbound tun-in: invalid settings: invalid value: integer `70000`, expected u16.

For a WireGuard outbound’s mtu, stay between 1280 and the 1420 default unless your provider specifies another value.

The defaults suit most deployments. This pair shows every configurable limit set explicitly, with the reason for each value in a comment. Both files pass etemenanki-app --test.

server.toml
# A Hysteria 2 server sized for a small group of users.
[[inbound]]
tag = "hy2-in"
protocol = "hysteria2"
listen = "0.0.0.0"
port = 443
[inbound.settings]
cert_file = "/etc/etemenanki/cert.pem"
key_file = "/etc/etemenanki/key.pem"
password = "replace-with-a-long-random-password"
udp = true
udp_idle_timeout = 120 # keep quiet UDP sessions for 2 minutes; 2 to 600
max_connections = 512 # QUIC connections; default 262144
max_circuits = 16384 # TCP streams plus UDP associations; default 4194304
[[outbound]]
tag = "direct"
protocol = "freedom"

A TCP connection through a stream inbound (SOCKS, HTTP, Trojan, VLESS, VMess, Shadowsocks, AnyTLS or sss) passes these stages, and each stage has its own bound:

flowchart LR
  A["Accept: free handshake and connection slots"] --> T["Transport handshake: 10 s"]
  T --> P["Protocol request: 10 s"]
  P --> S["Sniffing: 300 ms or 4 KiB"]
  S --> D["Dial: DNS 5 s per query, TCP connect 10 s per address"]
  D --> R["Relay: finished after 300 s idle"]
  R -.-> K["Dead-peer checks: TCP keepalive, WebSocket and HTTP/2 pings"]
  • The transport handshake exists only when the inbound has a TLS, WebSocket, gRPC or REALITY transport. A plain TCP inbound goes straight to the protocol request.
  • Sniffing runs only when sniffing is on and the client asked for an IP address. See inbounds.
  • The protocol request limit ends as soon as the inbound has the destination, or for AnyTLS as soon as the client has authenticated. On an sss inbound the request header has header_timeout instead. On HTTP, Trojan, VLESS, VMess, Shadowsocks, AnyTLS and sss inbounds the connection is then under the relay idle limit, including while the outbound dials.
  • The dead-peer checks run for the whole life of the connection. They notice a peer that vanished without closing the connection, not one that is idle but still answering.

Hysteria 2 and TUN inbounds accept connections differently and have their own limits, described in Hysteria 2 and TUN.

Timeout Value Applies to What happens
Transport handshake 10 s Inbounds with network = "tls", "ws" or "grpc": the TLS handshake, the WebSocket upgrade, or the HTTP/2 preface The socket closes. Debug log: inbound transport failed: tls handshake timed out, with websocket or grpc in place of tls
REALITY handshake 10 s Inbounds with security = "reality" If it runs out before the server has decided on the client, the connection goes on to the cover site; after that, it closes. See REALITY
Protocol request, silence 10 s HTTP, Trojan, VLESS, VMess, Shadowsocks and AnyTLS inbounds: any 10 s without progress before the request is complete The connection closes: inbound handshake timed out after 10s
Protocol request, total 10 s from the client’s first byte The same inbounds The connection closes: client did not complete its request in time
SOCKS negotiation 10 s SOCKS inbound: greeting, authentication and request together The connection closes: client did not complete its request in time
sss request header header_timeout, default 10 s, from the moment the transport hands the stream over sss inbound The stream is refused: drained, or handed to the fallback. Debug log: … refused: no header within the header time
TUN first byte 10 s TCP flows on a TUN inbound. A flow is dialed only after the client sends something, so a protocol where the server speaks first, such as SMTP or MySQL, always ends here The flow closes: tun: the client never spoke
Sniffing window 300 ms or 4 KiB, whichever comes first Flows to an IP address with sniffing on The flow is routed on its address
DNS query 5 s per query The udp, tls and https backends of [dns]; A and AAAA are asked in parallel, each with its own 5 s That query fails with dns: query timed out; the lookup still succeeds if the other query returned an address
TCP connect 10 s per address freedom, and the connection to the server of socks, http, trojan, vless, vmess, shadowsocks, anytls and sss outbounds The next resolved address is tried
Hysteria 2 connect 10 s per address hysteria2 outbound: QUIC handshake and authentication The next resolved address is tried. When none answers: hysteria2: no address answered (...)
Hysteria 2 stream open 5 s hysteria2 outbound: opening one proxy stream on the shared connection The flow fails: hysteria2: timed out opening a proxy stream
Tunnel TCP connect 10 s per address wireguard outbound: a TCP connection inside the tunnel The next address is tried
Balancer probe probe_timeout, default 5 s Each member of a [[balancer]], name resolution included The member counts as down

The two protocol-request rows work together: a client that connects and says nothing is dropped after 10 seconds, and one that starts its request has 10 seconds from its first byte to finish it. So once the transport handshake is done, a slow client can hold a connection for at most about 20 seconds before it authenticates. Both messages are logged at debug level as the reason a connection ended, for example vless connection from Some(198.51.100.20) ended: inbound handshake timed out after 10s.

The system DNS backend has no timeout of its own: getaddrinfo applies the host resolver’s timeouts and retries.

Addresses are tried one after another, not raced. A name that resolves to three unreachable addresses takes 30 seconds to fail, and the error lists every attempt:

failed to connect to any address (192.0.2.10:443: connect to 192.0.2.10:443 timed out; 192.0.2.11:443: connect to 192.0.2.11:443 timed out; 192.0.2.12:443: connect to 192.0.2.12:443 timed out)

If a name has an address you cannot reach, such as an AAAA record on a host without working IPv6, set address_family on the outbound so it is skipped. See outbounds.

Timer Value Applies to What happens
Relay idle 300 s Connections on HTTP, Trojan, VLESS, VMess, Shadowsocks, AnyTLS and sss inbounds (for mux.cool and AnyTLS, the carrier connection), Hysteria 2 streams, and TUN TCP flows and UDP associations: nothing read in either direction for 300 s The relay is finished
Cover-site relay 300 s without a byte moving Connections a REALITY inbound passes on to its cover site, and streams an sss inbound hands to its fallback The relay ends
SOCKS relay idle checked every 300 s SOCKS CONNECT relays A relay that moved no bytes since the previous check closes with socks: relay idle, between 300 and 600 s after its last byte
SOCKS UDP association idle 300 s SOCKS UDP ASSOCIATE: no datagram in either direction The association ends
TCP keepalive first probe after 120 s of silence, then every 30 s; 3 unanswered probes drop the connection Every TCP connection an inbound accepts, and every connection an outbound dials to its proxy server A vanished peer is detected about 210 s after it went silent
WebSocket ping after 60 s without a frame sent or received WebSocket sessions, both sides A Ping is sent
WebSocket idle 300 s without a frame sent or received WebSocket sessions, both sides The session reads as closed
HTTP/2 ping every 60 s; the connection is judged dead only when nothing at all is heard from the peer for 20 s after a PING, and a PONG is owed within 300 s gRPC inbound connections The HTTP/2 connection and all its streams close
HTTP/2 idle 30 s with no open stream gRPC inbound connections The HTTP/2 connection closes with a GOAWAY
QUIC idle quic.max_idle_timeout, default 30 s Hysteria 2, both sides The QUIC connection closes
QUIC keepalive quic.keep_alive_period, default every 10 s hysteria2 outbound Keeps the connection alive while it is idle
Hysteria 2 UDP association udp_idle_timeout, default 60 s, checked once per second hysteria2 inbound with udp = true The association ends
TUN UDP flow udp_idle_timeout, default 60 s, no packet in either direction One client source talking to one peer on a TUN inbound The flow is retired. When every flow of a client source is retired, its association ends and frees its max_flows slot
WireGuard keepalive keepalive, off by default wireguard outbound An empty packet keeps the NAT mapping open
AnyTLS idle session idle_session_timeout, default 30 s, checked every idle_session_check_interval anytls outbound: a session with no stream The session is closed, except the newest min_idle_session ones

“Idle” means no payload. The relay idle timer restarts every time bytes arrive from the client or from the outbound, so a connection that carries a keepalive of its own, such as SSH’s ServerAliveInterval or a WebSocket application ping inside the tunnel, never reaches it. A long-poll or a quiet database connection that sends nothing for five minutes does.

TCP keepalive is set on sockets the proxy accepts and on sockets it dials to a proxy server. Connections that freedom opens directly to destinations use the operating system’s default, which on Linux is no keepalive. Unix-socket listeners have no TCP keepalive.

The WebSocket and HTTP/2 pings are answered by any live peer, so they never close a connection that is only idle. On the dialing side, each flow over gRPC opens its own HTTP/2 connection, which relies on TCP keepalive and the relay idle limit.

What Value Details
accept() failure on a listener 100 ms pause For example when the process runs out of file descriptors. The log says accept error, backing off 100ms: Too many open files (os error 24)
hysteria2 outbound reconnect 2 s, doubling up to 30 s After a failed connect, or a connection that lived less than 10 s. A connection that lived longer is replaced at once. Flows that arrive during the wait fail with hysteria2: connection is down, waiting before the next attempt
wireguard outbound rebuild 2 s, doubling up to 30 s Same rule as Hysteria 2. Flows that arrive during the wait fail with wireguard: tunnel is down, waiting before the next attempt
Balancer probe probe_interval, default 30 s The wait after each probe ends, per member

Every inbound that accepts sockets, that is every protocol except hysteria2 and tun, on TCP or on a Unix socket, has two fixed limits, counted per inbound:

Limit Value Counts At the limit
Live connections 4,194,304 Accepted sockets, from accept until close A new connection is closed as soon as it is accepted. Debug log: dropping inbound connection; live connection limit reached
Concurrent handshakes 204,800 Connections still in their handshake A new connection is closed as soon as it is accepted. Debug log: dropping inbound connection; handshake limit reached

Both are guardrails against floods, not quotas. In practice the process’s open-file limit is reached first: each proxied connection holds one descriptor for the client and usually one for the outbound. Under systemd, set LimitNOFILE= as shown in running etemenanki-app.

Trojan, VLESS and VMess inbounds accept Xray’s mux.cool multiplexing automatically.

Limit Value At the limit
Sub-flows per carrier connection 256 A new sub-flow is ended at once; the carrier and its other sub-flows keep running
Data block per frame 8 KiB, as in Xray The carrier closes: mux: data length N exceeds 8192
Frame metadata 512 bytes, as in Xray The carrier closes: mux: metadata length N exceeds 512

An AnyTLS connection carries many streams by its own framing. None of these values is configurable.

Limit Value At the limit
Streams per connection 256 The inbound closes a further stream at once; the connection and its other streams keep running
UDP packet 8 KiB A larger packet is skipped
UDP packets split across frames 64 KiB held per connection A split packet past the budget is skipped
Settings frame 4 KiB The connection ends

UDP is routed packet by packet, and each association keeps one sub-link per outbound it has used. An association holds at most 64 sub-links; the 65th closes the one it sent to least recently. You reach this only with more than 64 distinct outbounds in one association. Outbounds explains the fan-out in detail.

Limit Value Side Counts At the limit
max_connections default 262,144 inbound QUIC connections on the listener, authenticated or not The QUIC handshake is refused. Debug log: hysteria2: refusing a connection; the listener is full or stopping
max_circuits default 4,194,304 inbound TCP streams plus UDP associations, across all connections on the listener A new stream is reset (hysteria2: refusing a stream; the listener is at its circuit limit); a new association’s packets are dropped
Streams per client connection quic.max_incoming_streams, default 65,536 inbound Open bidirectional streams on one QUIC connection The client waits for QUIC stream credit
UDP associations per connection 256 both Live UDP sessions on one QUIC connection Inbound: packets for a new session are dropped. Outbound: hysteria2: connection is at its UDP association limit
max_concurrent_streams default 102,400 outbound Open proxy streams on the outbound’s one shared connection, for all users together The flow fails at once: hysteria2: connection is at its concurrent-stream limit
Receive windows quic.max_stream_receive_window and quic.max_conn_receive_window, default 8 MiB per stream and 20 MiB per connection both Flow control The sender waits
UDP packet after reassembly 4096 bytes both Fragments are reassembled to at most this size The packet is dropped

A circuit holds its max_circuits slot for its whole life, until its relay ends or its association times out.

The two stream limits interact on the outbound. An etemenanki-app server grants each connection 65,536 streams. With the default max_concurrent_streams = 102400, the outbound never refuses a stream itself: the 65,537th concurrent flow waits for the server’s credit and fails after 5 seconds with hysteria2: timed out opening a proxy stream. Setting max_concurrent_streams to the server’s limit, as in the client example above, makes such a flow fail immediately instead. The Hysteria 2 page has the other Hysteria-specific values.

Limit Value Counts At the limit
max_flows default 65,536 TCP connections, plus one UDP association per client source address and port The new TCP connection or association is dropped. Debug log: tun: dropping a flow; the flow limit is reached
New peers queued per UDP source 16 Peers a client source has just addressed that its association has not picked up yet The first packet to a further new peer is dropped; the client’s retransmission gets through once the queue drains

A routing loop, where an outbound’s own traffic is steered back into the device, fills max_flows quickly. The TUN page explains how to keep the proxy’s own traffic off the device.

Every flow routed to a wireguard outbound shares one tunnel and one driver task, but each flow has its own fixed buffers between the application and the tunnel. None of them is configurable.

Buffer Value Per At the limit
TCP socket buffers 64 KiB in each direction Tunnel TCP connection Uplink: further writes stay in the channel. Downlink: the remote waits for the tunnel’s TCP window
TCP channel 256 writes toward the tunnel, 256 reads toward the client, plus at most one write the driver has taken but the socket has not accepted Tunnel TCP connection Uplink: the next write waits until the remote reads again. Downlink: the driver stops reading the socket until the client reads
UDP rings 64 KiB and 64 datagrams in each direction UDP association Send: a datagram that finds the ring full waits for the next pass. A datagram larger than the whole ring, or to an unaddressable destination such as port 0, is dropped. Receive: a datagram that arrives while the ring is full is dropped
UDP channel 256 datagrams in each direction, plus at most one held datagram toward the tunnel UDP association Uplink: the sender waits. Downlink: the driver stops reading the ring until the client reads

At the limit, only the stalled flow waits: every other flow on the same tunnel keeps moving. A dropped outgoing datagram is logged only at trace level, as wireguard: dropping a N-byte datagram to <addr>: <error>. One slow flow on the WireGuard page walks through the same buffers in order.

What Value
Cached names 8192; when full, entries are evicted whatever their TTL
TTL from a DNS answer (udp, tls, https) Clamped to 5 s minimum, 3600 s maximum
TTL for the system backend 60 s, since getaddrinfo reports none

None of these is configurable. The cache is kept across reloads as long as [dns] does not change. With a subscribe file’s [dns], the service that answers applications’ own DNS queries holds at most 64 queries in flight per UDP association and drops a further one. DNS covers the resolver in full.

Limit Value Side At the limit
WebSocket message and frame 1 MiB both The session fails
WebSocket early data 16 KiB both Inbound: the upgrade is answered 413 Payload Too Large. Outbound: an ?ed= value above 16 KiB is capped
gRPC message 1 MiB both The stream fails: grpc message length exceeds the accepted maximum
HTTP/2 windows and frames 4 MiB per stream, 16 MiB per connection, 256 KiB frame both Flow control; the sender waits

Tunneled payloads are far smaller than these caps. The caps stop a hostile peer from making the server buffer a message of its own choosing. Transports describes each carrier.

Limit Value Applies to At the limit
HTTP request head 64 KiB, at most 128 headers http inbound The connection closes: http head exceeds maximum size, or malformed http request: too many headers
Trojan UDP payload 8192 bytes per packet trojan inbound The association ends: trojan: oversize payload
Reply datagram delivered whole 8192 bytes for Trojan, VLESS, VMess and AnyTLS; 4096 bytes for Hysteria 2 and TUN; 64 KiB for SOCKS UDP replies from an outbound to the client Longer replies are truncated, as a kernel recv into a short buffer would
sss UDP record udp_max_datagram, default 65535 bytes sss, both sides A record from the client above it fails the stream; a reply above it is dropped
VMess clock skew 120 s either way, unless clock_check = false vmess inbound The client cannot authenticate; see VMess
Shadowsocks 2022 clock skew 30 s either way shadowsocks with a 2022- method The request is refused: shadowsocks-2022: bad timestamp

UDP support depends on both ends: the inbound must relay datagrams, and the outbound each packet is routed to must carry them.

Protocol As an inbound As an outbound
socks Yes, by UDP ASSOCIATE when udp = true (the default), over plain TCP only; SOCKS4 has no UDP Yes, by UDP ASSOCIATE; the datagrams go to the server’s relay port as plain UDP
http No No
shadowsocks (all methods) No No
trojan Yes, always on; also mux.cool with XUDP Yes, inside the Trojan connection
vless Yes, always on; also mux.cool with XUDP Yes, inside the VLESS connection. Without a flow the framing has no per-packet address, so every packet goes to the destination of the packet that opened the sub-link. With flow = "xtls-rprx-vision" the packets ride XUDP, each addressed to its own peer
vmess Yes, always on; also mux.cool with XUDP Yes, inside the VMess connection, with the same one-destination rule as VLESS without a flow
anytls Yes, always on, as UDP-over-TCP streams Yes, as a UDP-over-TCP stream with an address on every packet
sss Yes, always on Yes, one stream per UDP flow, with an address on every record
hysteria2 Only with udp = true (off by default) Yes, as QUIC datagrams, if the server allows UDP
tun Yes when udp = true (the default) not an outbound
wireguard not an inbound Yes
freedom not an inbound Yes, one socket per address family
blackhole not an inbound Accepted and discarded
a balancer not an inbound As its chosen member

What happens when the two ends do not match:

  • The inbound has no UDP. An HTTP or Shadowsocks client has no way to ask for UDP. A SOCKS5 client asking for UDP ASSOCIATE on an inbound with udp = false gets “command not supported”. A Hysteria 2 server with udp = false tells each client at authentication that it does not relay UDP.
  • The outbound has no UDP. The router does not know which outbounds carry datagrams. A packet routed to http or shadowsocks is dropped, and the association’s other packets carry on. The debug log shows udp fan-out: opening <tag>@v<n> failed: http carries no datagrams, or shadowsocks / shadowsocks-2022 in place of http. Put a network = "udp" rule before the rule that would send UDP there.
  • The Hysteria 2 server refuses UDP. Packets routed to a hysteria2 outbound whose server has UDP off are dropped. The outbound logs one warning, and the debug log shows udp fan-out: opening <tag>@v<n> failed: hysteria2: the server does not relay UDP.

Rules see each UDP packet on its own; see routing and how UDP reaches an outbound.

Configuration errors appear when the file is loaded or checked with --test, prefixed with configuration invalid:. Run-time messages are logged at debug level unless noted, so raise [log].level to see them.

Message Cause Fix
inbound TAG: max_connections and max_circuits must be at least 1 A Hysteria 2 limit is 0 Remove the key for the default, or set 1 or more
inbound TAG: udp_idle_timeout must be between 2 and 600 seconds Hysteria 2 udp_idle_timeout out of range Use 2 to 600
inbound TAG: udp_idle_timeout is set but udp is not enabled udp_idle_timeout on a Hysteria 2 inbound without udp = true Add udp = true or remove the key
outbound TAG@v0: max_concurrent_streams must be at least 1 max_concurrent_streams = 0 Remove the key or set 1 or more
inbound TAG: tun mtu must be at least 1280 TUN mtu below 1280 Use 1280 or more
inbound TAG: sss header_timeout must be above zero header_timeout = "0s" on an sss inbound Use a positive duration
inbound TAG: sss flush_delay must be at most 10ms sss flush_delay above 10 ms Lower it
inbound TAG: sss udp_max_datagram must be at least 1 udp_max_datagram = 0 Use 1 to 65535 on both ends
TOML parse error at line <n>, column <m>, at a duration A duration written as a string, such as "30s" Write whole seconds: probe_interval = 30
accept error, backing off 100ms: Too many open files (os error 24) (warning) The process ran out of file descriptors Raise the open-file limit, for example LimitNOFILE= under systemd
dropping inbound connection; live connection limit reached 4,194,304 live connections on one inbound Spread clients over several inbounds or hosts
dropping inbound connection; handshake limit reached 204,800 connections in their handshake at once, usually a scan or flood Filter the source in a firewall
inbound handshake timed out after 10s A client connected and sent nothing, or stalled for 10 s Check the client’s protocol, port and transport settings
client did not complete its request in time A client started its request and did not finish it within 10 s A stalled or very slow client, or one that sends only part of the request
failed to connect to any address (...) Every resolved address refused or timed out after 10 s Check the destination, or restrict address_family
dns: query timed out The DNS server did not answer within 5 s Check [dns].server and the path to it
hysteria2: timed out opening a proxy stream The server withheld stream credit for 5 s Lower max_concurrent_streams to fail fast, or add a second outbound
hysteria2: connection is at its concurrent-stream limit max_concurrent_streams flows are open on the outbound Raise max_concurrent_streams
hysteria2: refusing a connection; the listener is full or stopping max_connections QUIC connections are live Raise max_connections
hysteria2: refusing a stream; the listener is at its circuit limit max_circuits circuits are live Raise max_circuits
tun: dropping a flow; the flow limit is reached max_flows flows are live, or a routing loop Fix the loop, or raise max_flows
grpc message length exceeds the accepted maximum The peer sent a gRPC message over 1 MiB The peer is not a standard gRPC tunnel client