Skip to content
Guides

Send test messages over MLLP

Send a synthetic HL7v2 message to a MedHook MLLP listener with nc or the mllp-send command, read the ACK, and find the message in MedHook.

On this page
Send test messages over MLLP. Send a synthetic HL7v2 ADT^A01 to a MedHook MLLP listener with an nc one-liner and read the ACK, then use mllp-send to send a built-in sample, a file, and a resend with a fresh control ID, and find each message and its run in Messages.

This guide sends a test HL7v2 message to a MedHook MLLP listener and reads the ACK that comes back. First with nc, which every machine has, then with mllp-send, a small command that splits batch files, checks each ACK and sets its exit code for scripts. At the end you find the message in MedHook.

Here is the flow.

sequenceDiagram
    participant You
    participant Listener as MLLP listener
    participant Engine as MedHook engine
    You->>Listener: VT, ADT^A01, FS, CR
    Listener->>Engine: The message
    Engine-->>Listener: AA, AE or AR
    Listener-->>You: VT, ACK (MSA), FS, CR
    Engine->>Engine: Run the workflow

Before you start

  • An MLLP listener you can reach. On the Quick start stack it is localhost:2575. On a deployed engine, ask for its MLLP host and port, for example mllp.example.test:2575, and whether that port uses TLS.
  • A deployed workflow whose MLLP trigger takes the message type you send, such as the one in HL7v2 over MLLP to a JSON webhook. Without one, the listener answers AR.
  • Synthetic data only. The examples use TESTPATIENT and set MSH-11 to T, which marks a test message. Never paste a real patient's message into a test.

Send with nc

MLLP wraps each message in a start byte 0x0B and the end bytes 0x1C 0x0D, and HL7v2 ends each segment with a carriage return (CR), not a line feed. This sends message.hl7, turns its line endings into CR, and prints the ACK:

bash
(printf '\013%s\034\015' "$(tr -d '\r' < message.hl7 | tr '\n' '\r')"; sleep 5) | nc localhost 2575 | tr '\r' '\n'

printf with octal escapes works in every shell, unlike echo -e. The final tr puts each ACK segment on its own line.

The sleep 5 matters. The listener answers on the same connection, and many nc builds, including the one in macOS, close the connection as soon as their input ends, before the ACK arrives. Keeping the input open for five seconds works with every nc. Some builds have a flag for it instead:

Your ncCommand
Any, including macOS and BSD(printf ...; sleep 5) | nc localhost 2575
Linux netcat-openbsd (Debian, Ubuntu) or GNU netcatprintf ... | nc -q 5 localhost 2575 (wait 5 seconds after the input ends)
Nmap ncatprintf ... | ncat --no-shutdown -i 5s localhost 2575

A good reply looks like this. MSA-1 is the ACK code and MSA-2 the control ID (MSH-10) of your message:

text
MSH|^~\&|MEDHOOK|MEDHOOK|LABSYS|DEMOCLINIC|20261021120001||ACK|ACK1|T|2.5.1
MSA|AA|MSG00001|

nc sends one message as it is, plain TCP only. For batch files, TLS, or a check you can script, use mllp-send.

Send with mllp-send

mllp-send is one file with no dependencies, for macOS, Linux and Windows. It reads a single message, an HL7 batch file (FHS/BHS ... BTS/FTS), an MLLP capture, or a Mirth or Rhapsody message export. It changes LF and CRLF line endings to CR, removes MLLP framing already in the file, frames each message, waits for its ACK and checks that MSA-2 names the message it sent. It prints control IDs and ACK codes, never message content. -sample sends a built-in synthetic message, so you need no file at all.

Download

Version v1.0.0-rc.16-5-gcfd78e84. All checksums in one file: SHA256SUMS.

PlatformDownloadSHA-256
macOS, Apple silicon (arm64)mllp-send-darwin-arm6476cb5a1e49802c3c39572681c13791f4b6262b93f5fdeb6402c9ceebbe83cc63
macOS, Intel (x86-64)mllp-send-darwin-amd6495842ae505ed7416ae21c781a2f809eb59972937efff9208c9733b54d8f39de1
Linux, x86-64mllp-send-linux-amd640653c6da9ca223f7ee1cb51476d49963bcb474ab40d1a6c13a2d5f87b0bb1c90
Linux, arm64mllp-send-linux-arm64ca09df379ef95451ea546fc3749c3c8d96106b24335543a24340ee4e6c25e028
Windows, x86-64mllp-send-windows-amd64.exe39c5cd85e9524d2de00efd63bba75d661467e2b987e95164b42c81f9c75a10d1

Check the download

Compare the SHA-256 of the file you downloaded with the table above.

bash
# macOS
shasum -a 256 mllp-send-darwin-arm64

# Linux
sha256sum mllp-send-linux-amd64

# Or check every file you downloaded against SHA256SUMS (Linux)
sha256sum --check --ignore-missing SHA256SUMS
powershell
# Windows (PowerShell)
Get-FileHash .\mllp-send-windows-amd64.exe -Algorithm SHA256

Then make it runnable under a short name:

bash
mv mllp-send-darwin-arm64 mllp-send
chmod +x mllp-send

Examples

Send the built-in synthetic ADT^A01 to a local listener. Every run gets a fresh control ID, so the engine never drops it as a resend:

bash
mllp-send -sample

Send another sample type: ADT^A04, ADT^A08 or ORU^R01:

bash
mllp-send -sample -type ORU^R01 -host mllp.example.test -port 2575

Send a file, or read it from standard input:

bash
mllp-send -file message.hl7 -host mllp.example.test -port 2575
cat message.hl7 | mllp-send -file - -host mllp.example.test

Replay a batch file or an export at 2 messages per second. The default is 5 per second, and the most is 100. All messages go over one connection, in order:

bash
mllp-send -file export.hl7 -host mllp.example.test -port 2575 -rate 2

Send to a TLS listener. MedHook listeners serve TLS 1.2 or later. -ca names the CA that signed the listener's certificate; without it the system store is used. Add -cert and -key when the listener requires a client certificate:

bash
mllp-send -sample -host mllp.example.test -port 2576 -tls -ca ca.pem
mllp-send -sample -host mllp.example.test -port 2576 -tls -ca ca.pem -cert client.pem -key client-key.pem

-insecure skips the certificate check, for a first test against a self-signed listener only. Add -v to print each raw ACK, with its framing and segment ends shown as <VT>, <CR> and <FS>.

FlagDefaultWhat it does
-filenoneThe file to send. - reads standard input.
-sampleoffSend the built-in synthetic message instead of a file.
-typeADT^A01The sample's message type: ADT^A01, ADT^A04, ADT^A08 or ORU^R01.
-host, -portlocalhost, 2575The listener.
-timeout35sHow long to wait to connect, and for each ACK. Longer than the listener's 30-second MLLP_TIMEOUT, so its AE arrives first.
-rate5Messages per second for files with several messages. At most 100.
-new-idoffGive each message from -file a fresh MSH-10 before it is sent. With -v, prints each old and new control ID.
-tlsoffConnect with TLS 1.2 or later.
-ca, -cert, -key, -insecure, -servernamenoneTLS trust, client certificate and the name to check. Need -tls.
-voffAlso print each raw ACK.
-version, -hPrint the version, or the help.

Read the output

mllp-send prints one line per message: the ACK code, the control ID, then MSA-3 or what the code means. A batch also gets a summary on standard error.

text
sending 3 messages to mllp.example.test:2575 at 2/s
AA  MSG00001  Message accepted
AR  MSG00002  No matching triggers for message type ORU^R01
AA  MSG00003  Message accepted
3 messages: AA 2, AR 1; 0 errors; 0 rejected
CodeMeans
AAAccepted. MedHook has the message safely.
CACommit accept, from a listener in msh15 mode. The listener has it. It counts as success, and the line says it is a commit ACK.
AEA temporary error. Send it again later.
ARRejected for good. MSA-3 says why. Resending gets the same answer.
CECommit error. Send it again later.
CRCommit reject. Resending gets the same answer.

A line can also say delivery uncertain. The message was written to the connection, but nothing proves what happened to it: no ACK came within -timeout, the connection closed first, the ACK had no MSA segment, or its MSA-2 names another message. These lines show -- for the code, or the code of the ACK that named another message. Check Messages before you send it again. A line that starts not sent means the connection failed, so nothing was written. #3 rejected: on standard error means block 3 of the file is not a valid HL7v2 message, and it was not sent.

Exit codeWhen
0Every message got AA or CA.
1Any AE, AR, CE or CR, a missing ACK, an ACK for another message, a timeout, a message not sent, or a block of the file rejected.
2A usage or file error: a bad flag, a file that cannot be read, or a file with no HL7v2 message in it. Nothing was sent.

Find the message in MedHook

Open the engine UI.

  • AA. The message is in Messages. Search for its control ID: paste it, or type MSH.10:MSG00001 (or control:MSG00001). Both look it up in an index, at any age. Open it to see the run of each workflow it started, step by step. AA means MedHook recorded the message, not that the workflow finished, so check the run.
  • A run fails after the AA. The message also waits on Messages › Needs action, grouped as AE · rejected or AR · rejected by the failure. Fix the cause, then replay it there. See Executions and replay.
  • AR with "No matching triggers". No workflow took the message, so it is not in Messages. MSA-3 says why.
  • AA, but no new run. The engine already accepted that message (the same MSH-10 from that sender, with the same content) and dropped the resend. To run the same file again, add -new-id: each message gets a fresh control ID, and nothing else in it changes. Add -v to see which new ID belongs to which original. See Resends and MSH-10.

🎉 You can now send a test message and know what MedHook did with it. Next, send a batch export from your current engine with -rate, or read MLLP and ACKs for every ACK the listener sends.

Troubleshooting

  • No ACK, or "connection refused". Check the port: MLLP_PORT is 2575 by default, and a TLS listener has a port of its own. A firewall, a security group or a missing port-forward drops the connection or never answers. A plain connection to a TLS port, or -tls to a plain port, gets no ACK either.
  • No ACK from nc, but mllp-send works. Your nc closed the connection when its input ended. Use the sleep 5 form above.
  • The listener answers AR: "No matching triggers for message type ORU^R01". No deployed workflow takes that message. Check that the workflow is Active and that its trigger's Message types, sending facility and inbound filter accept the message. -sample -type sends another type to compare.
  • LF line endings. Files saved on macOS, Linux or Windows end lines with LF or CRLF, but HL7v2 needs CR. mllp-send converts them. With nc, keep the tr commands in the one-liner. Without them the message arrives with LF segment ends, which HL7v2 does not allow, and it can be rejected or read wrong.
  • AA, but nothing new in Messages. The control ID was sent before. Send the file again with -new-id, or use -sample, which always makes a fresh one.
  • Delivery uncertain: no ACK within 35s. The listener waits up to MLLP_TIMEOUT (30 seconds) for the engine, and longer when the trigger waits for its destinations. The default -timeout of 35 seconds outlasts the listener; raise it when the trigger waits for its destinations, then check Messages before you resend.
  • AE. The engine could not record the message, for example while its database is down. Check GET /api/health, then send again.

Reference