Interface: ClientOptions
Options for createClient and the MllpClient constructor.
Example
const opts: ClientOptions = { host: 'localhost', port: 2575, drainTimeoutMs: 10_000 };
Properties
ackTimeoutMs?
readonlyoptionalackTimeoutMs?:number
Per-message ACK timeout in milliseconds. The clock starts at
the underlying write() flush callback, NOT at the send() call,
pre-flush queue time is not charged to the peer. Default: 30_000.
autoReconnect?
readonlyoptionalautoReconnect?:boolean
Auto-reconnect on transient disconnect. Default false.
When true, dropped connections caused by transient errors (per
isTransientConnectionError) trigger the FSM cycle
CONNECTED → DISCONNECTED → RECONNECTING → CONNECTING → CONNECTED
with exponential backoff unless overridden by
ClientOptions.retryStrategy. Permanent errors halt and
transition directly to CLOSED.
correlateByControlId?
readonlyoptionalcorrelateByControlId?:boolean
If true, ACKs are matched against outgoing sends by MSH-10 → MSA-2.
Default false (FIFO mode).
Out-of-order ACKs from the peer are supported in this mode. MSH-10 is
extracted from the outbound payload before send; MSA-2 is extracted from
the inbound ACK payload. An ACK whose MSA-2 matches no pending send
(and is not in the late-ACK graveyard) emits a frozen
MllpFramingError('MLLP_ACK_UNMATCHED_CONTROL_ID') to the 'error' event.
A late ACK whose MSA-2 matches a graveyard entry emits a
MLLP_ACK_AFTER_TIMEOUT warning and is dropped.
Default
false
deadPeerTimeoutMs?
readonlyoptionaldeadPeerTimeoutMs?:number
Application-idle timeout (ms) keyed on last inbound bytes / ACK / warning.
On trip, calls connection.destroy(new Error('dead peer timeout')) which surfaces as MllpConnectionError({ phase: 'receive' }).
Trip honors ClientOptions.autoReconnect. Independent of
ClientOptions.keepaliveIntervalMs.
Default
undefined (off)
drainTimeoutMs?
readonlyoptionaldrainTimeoutMs?:number
Drain timeout for MllpClient.close (default: 30_000 ms).
framing?
readonlyoptionalframing?:Omit<FrameReaderOptions,"onFrame"|"onWarning">
FrameReader tolerance / size options. onFrame and onWarning are managed internally.
highWaterMark?
readonlyoptionalhighWaterMark?:HighWaterMark
Application-level high-water mark on the in-flight + queued send set.
number configures a count cap (default 64);
{ bytes } configures a byte cap; { count, bytes } configures
both, with the stricter-of-two trigger winning.
When the cap is exceeded, behavior is governed by ClientOptions.onBackpressure.
Default
64
host
readonlyhost:string
Host to connect to (e.g. 'localhost' or 'mllp.example.com').
initialDelayMs?
readonlyoptionalinitialDelayMs?:number
First delay (ms) on auto-reconnect; default 100.
jitter?
readonlyoptionaljitter?:number
Jitter fraction, e.g. 0.2 = ±20%; default 0.2.
keepaliveIntervalMs?
readonlyoptionalkeepaliveIntervalMs?:number
TCP keepalive interval (ms). Sets socket.setKeepAlive(true, ms) on
the underlying net.Socket BEFORE wrapping in NetTransport. OS-level
half-open detection (network partitions, NAT-table eviction). Independent
of ClientOptions.deadPeerTimeoutMs.
Default
undefined (off)
maxDelayMs?
readonlyoptionalmaxDelayMs?:number
Maximum backoff cap (ms); default 30_000.
multiplier?
readonlyoptionalmultiplier?:number
Backoff multiplier; default 2.
onBackpressure?
readonlyoptionalonBackpressure?:"reject"|"wait"
Behavior when the high-water mark is exceeded.
'reject'(default),send()rejects withMllpBackpressureError.'wait',send()awaits the'drain'event OR the per-messageackTimeoutMsORsignalabort, whichever fires first.
Default
'reject'
pipeline?
readonlyoptionalpipeline?:boolean
Strict serialization send → await-ACK → send.
true(default), concurrent in-flight sends up to ClientOptions.highWaterMark.false, collapses the in-flight set to ≤1 (the unified Correlator'smaxInFlight=1); the nextsend()waits for the prior ACK before reaching the wire.
Default
true
port
readonlyport:number
TCP port.
retryStrategy?
readonlyoptionalretryStrategy?:RetryStrategy
Custom reconnect-backoff hook. Return null to halt
reconnection. Receives a frozen RetryContext. Defaults
to the exponential strategy.
tls?
readonlyoptionaltls?:true|TlsOptions
Enable TLS (MLLPS) for this connection. true enables TLS with
all defaults, including certificate verification on. Pass a
TlsOptions object to customize (ca/cert/key, minimum
version, ciphers, allowUnverified, …).
Spec anchor: IHE ATNA ITI-19 (https://profiles.ihe.net/ITI/TF/Volume2/ITI-19.html).
Default
undefined (plaintext TCP)