Skip to main content
Version: v0.0.3

Interface: ClientOptions

Options for createClient and the MllpClient constructor.

Example

const opts: ClientOptions = { host: 'localhost', port: 2575, drainTimeoutMs: 10_000 };

Properties

ackTimeoutMs?

readonly optional ackTimeoutMs?: 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?

readonly optional autoReconnect?: 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?

readonly optional correlateByControlId?: 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?

readonly optional deadPeerTimeoutMs?: 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?

readonly optional drainTimeoutMs?: number

Drain timeout for MllpClient.close (default: 30_000 ms).


framing?

readonly optional framing?: Omit<FrameReaderOptions, "onFrame" | "onWarning">

FrameReader tolerance / size options. onFrame and onWarning are managed internally.


highWaterMark?

readonly optional highWaterMark?: 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

readonly host: string

Host to connect to (e.g. 'localhost' or 'mllp.example.com').


initialDelayMs?

readonly optional initialDelayMs?: number

First delay (ms) on auto-reconnect; default 100.


jitter?

readonly optional jitter?: number

Jitter fraction, e.g. 0.2 = ±20%; default 0.2.


keepaliveIntervalMs?

readonly optional keepaliveIntervalMs?: 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?

readonly optional maxDelayMs?: number

Maximum backoff cap (ms); default 30_000.


multiplier?

readonly optional multiplier?: number

Backoff multiplier; default 2.


onBackpressure?

readonly optional onBackpressure?: "reject" | "wait"

Behavior when the high-water mark is exceeded.

  • 'reject' (default), send() rejects with MllpBackpressureError.
  • 'wait', send() awaits the 'drain' event OR the per-message ackTimeoutMs OR signal abort, whichever fires first.

Default

'reject'

pipeline?

readonly optional pipeline?: 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's maxInFlight=1); the next send() waits for the prior ACK before reaching the wire.

Default

true

port

readonly port: number

TCP port.


retryStrategy?

readonly optional retryStrategy?: RetryStrategy

Custom reconnect-backoff hook. Return null to halt reconnection. Receives a frozen RetryContext. Defaults to the exponential strategy.


tls?

readonly optional tls?: 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)