Skip to main content
Version: v0.1.8

@cosyte/mllp

@cosyte/mllp is our MLLP client and server for HL7 v2 in Node.js and TypeScript. MLLP (the Minimal Lower Layer Protocol) is how HL7 v2 messages travel over TCP: each message is wrapped in three framing bytes, and the receiver answers with an acknowledgment. This package carries those bytes and gives you the parts the protocol leaves to you:

  • Framing. A strict encoder that always writes the canonical block (VT payload FS CR), and a decoder that tolerates the quirks real senders have, one opt-in flag at a time, with a stable warning code for each.
  • Acknowledgments. A client whose send() resolves with the acknowledgment for that message, not the next bytes off the wire, and a server that only answers AA after your handler has committed the message.
  • A connection that lasts. Auto-reconnect with backoff and jitter, dead-peer detection, backpressure with a bounded queue, and a shutdown that waits for outstanding acknowledgments.
  • TLS. Verification on by default, mutual TLS, a TLS 1.2 floor, and the IHE ATNA cipher suites as an opt-in.
  • Testing. An in-memory transport so your tests open no socket, and a harness that observes how an engine you name frames and acknowledges.

It has no runtime dependencies: the client, the server and the codec use Node.js built-ins only. It is published on npm under the MIT license.

Who it is for​

Developers who connect a Node.js service to a hospital interface engine, a lab system or another HL7 v2 sender or receiver, and who need the transport to fail safely: a message that was not committed must never be acknowledged as if it were.

What it is not​

  • Not a parser. It never reads the payload. Pair it with @cosyte/hl7 or any other parser to read fields. The one exception is the optional @cosyte/mllp/ack-from-hl7 subpath, which builds an acknowledgment through @cosyte/hl7.
  • Not a queue. It holds a message in memory only until its acknowledgment settles it, and keeps nothing across a restart. MLLP with an HL7 acknowledgment is at-least-once at best, and de-duplication belongs to the application.
  • Not MLLP Release 2. Only Release 1 framing is implemented.

Known limitations and non-goals lists every bound, and is worth reading before you depend on the package.

The package at a glance​

Entry pointWhat it holds
@cosyte/mllpthe client, the server, the framing codec, TLS, and the differential harness
@cosyte/mllp/testingInMemoryTransport, two connected in-process ends for socket-free tests
@cosyte/mllp/ack-from-hl7acknowledgment builders over the optional @cosyte/hl7 peer
@cosyte/mllp/arbitrariesfast-check generators of frames and streams, over the optional fast-check peer

Next​