internal/webfetchhelp/text/websocket.txt
WEBSOCKET AND STREAM REFERENCE
USAGE
ez-agent-webfetch [WEBSOCKET OPTIONS] ws://URL
ez-agent-webfetch [WEBSOCKET OPTIONS] wss://URL
MODES
--ws-mode stream|framed
stream is the payload-only default. framed preserves application-message
type and completion with local O/T/B/D/E/C records; see --help-framed.
WARNING: stream mode requires an endpoint that treats consecutive outgoing
WebSocket messages as one logical byte stream. It is not a TCP adapter for an
endpoint that depends on message boundaries; use framed mode for such services.
STREAM SEND
--ws-type text|binary
Select outgoing stream messages only; default text. Incoming text and binary
payloads are both accepted and flattened identically to stdout. Text sends
and receives are incrementally UTF-8 validated.
--ws-frame-size N
Maximum outgoing stream application-message payload; default and hard
maximum 65,536. Text mode accepts 4 through 65,536 so every UTF-8 code
point can fit in a complete message. Binary mode accepts 1 through 65,536.
Larger stdin reads are split. Text mode backs off rather than splitting a
UTF-8 code point.
--ws-frame-delay DURATION
Nonnegative input-idle coalescing delay, default 10ms. A message is completed
when its size limit is reached, the resettable idle delay expires, or stdin
reaches EOF. Every generated send is a complete application message; the
library owns any lower-level wire fragmentation.
STREAM RECEIVE AND EOF
Incoming message readers are copied to stdout in bounded chunks. Stream mode
inserts no newline, delimiter, status, type, open, close, or framing metadata;
peer message boundaries and types are intentionally discarded.
--ws-eof-timeout DURATION
Nonnegative receive-idle grace after stdin EOF, default 10s. EOF flushes a
pending outgoing message, stops application sends, and continues forwarding
peer data. Successful peer payload writes, as well as a successfully delivered
empty message, reset the timer. A peer Close available at expiry or observed
during the idle close handshake is classified normally and remains
authoritative. Otherwise idle expiry completes a normal close and is
successful. Zero waits indefinitely. WebSocket has no write half-close, so
the peer receives no generic input-EOF notification before eventual close.
HANDSHAKE AND CONNECTION OPTIONS
-H, --header 'Name: value'
Repeat handshake headers. Host is special; Origin is an ordinary header.
Connection, Upgrade, Sec-WebSocket-Key, Sec-WebSocket-Version,
Sec-WebSocket-Protocol, and Sec-WebSocket-Extensions are protocol-owned and
rejected. Use the dedicated options below.
-A, --user-agent VALUE
Explicit value (including empty), then last User-Agent header, then the
EzAgent/<version> default.
--sensitive-header NAME
Repeat a valid caller-defined handshake field name that must not cross an
origin boundary. Supply its value separately with --header.
Handshake redirects use normalized scheme, hostname, and effective port and
stop after ten redirects. Authorization, Cookie, Proxy-Authorization, URL
credentials, and caller-marked fields cause a cross-origin redirect or WSS-to-WS
downgrade to fail rather than forwarding secrets.
--ws-subprotocol NAME
Repeat an ordered list of unique valid protocol tokens.
--ws-compression disabled|no-context|context
disabled is the default. The other modes request per-message compression
without or with context takeover.
--ws-max-message N
The default is 10 MiB. A positive value through 9,223,372,036,854,775,806
caps each complete incoming and outgoing application message. Explicit zero
opts into unlimited message size with bounded streaming memory. The upper
bound preserves exact enforcement by the WebSocket dependency. Stream frame
size may not exceed a positive cap.
--ws-ping-interval DURATION
Zero disables managed pings. A positive interval enables serialized liveness
probes; overlapping ticks are skipped and pinging stops when close begins.
--timeout DURATION
Nonnegative network-connection lifetime; zero means no deadline. After
local inputs are loaded, it includes proxy, DNS, handshake, all data
transfer, and close lifecycle. The caller coordinates readiness and
delivery for local --header-file paths, including FIFOs.
CLOSES AND FAILURES
Peer close codes 1000, 1001, and clean code-less close (reported locally as
1005) are successful unless another error won. Abnormal/application error
closes, invalid text, excessive messages, abrupt transport loss, ping failure,
total timeout, signal, and I/O failure exit 1. A blocked terminal stdin does not
prevent process exit after peer closure. Stream stdout may contain a valid
prefix before a later failure.
TLS AND PROXIES
WSS verifies hostnames and certificates using the system root CA store. There
is no insecure TLS mode. WS is plaintext. Standard Go HTTP_PROXY, HTTPS_PROXY,
and NO_PROXY behavior is retained, including supported SOCKS proxy URLs. The
WebSocket Upgrade uses HTTP/1 while ordinary HTTP transport capability remains.
EXAMPLES
producer | ez-agent-webfetch --ws-type binary --ws-eof-timeout 30s \
-H 'Authorization: Bearer token' wss://example.test/tunnel | consumer
controller | ez-agent-webfetch --ws-mode framed \
--ws-subprotocol chat wss://example.test/messages