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
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 workflowBefore 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 examplemllp.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
TESTPATIENTand set MSH-11 toT, 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:
(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 nc | Command |
|---|---|
| Any, including macOS and BSD | (printf ...; sleep 5) | nc localhost 2575 |
Linux netcat-openbsd (Debian, Ubuntu) or GNU netcat | printf ... | nc -q 5 localhost 2575 (wait 5 seconds after the input ends) |
Nmap ncat | printf ... | 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:
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.
| Platform | Download | SHA-256 |
|---|---|---|
| macOS, Apple silicon (arm64) | mllp-send-darwin-arm64 | 76cb5a1e49802c3c39572681c13791f4b6262b93f5fdeb6402c9ceebbe83cc63 |
| macOS, Intel (x86-64) | mllp-send-darwin-amd64 | 95842ae505ed7416ae21c781a2f809eb59972937efff9208c9733b54d8f39de1 |
| Linux, x86-64 | mllp-send-linux-amd64 | 0653c6da9ca223f7ee1cb51476d49963bcb474ab40d1a6c13a2d5f87b0bb1c90 |
| Linux, arm64 | mllp-send-linux-arm64 | ca09df379ef95451ea546fc3749c3c8d96106b24335543a24340ee4e6c25e028 |
| Windows, x86-64 | mllp-send-windows-amd64.exe | 39c5cd85e9524d2de00efd63bba75d661467e2b987e95164b42c81f9c75a10d1 |
Check the download
Compare the SHA-256 of the file you downloaded with the table above.
# 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# Windows (PowerShell)
Get-FileHash .\mllp-send-windows-amd64.exe -Algorithm SHA256Then make it runnable under a short name:
mv mllp-send-darwin-arm64 mllp-send
chmod +x mllp-sendExamples
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:
mllp-send -sampleSend another sample type: ADT^A04, ADT^A08 or ORU^R01:
mllp-send -sample -type ORU^R01 -host mllp.example.test -port 2575Send a file, or read it from standard input:
mllp-send -file message.hl7 -host mllp.example.test -port 2575
cat message.hl7 | mllp-send -file - -host mllp.example.testReplay 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:
mllp-send -file export.hl7 -host mllp.example.test -port 2575 -rate 2Send 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:
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>.
| Flag | Default | What it does |
|---|---|---|
-file | none | The file to send. - reads standard input. |
-sample | off | Send the built-in synthetic message instead of a file. |
-type | ADT^A01 | The sample's message type: ADT^A01, ADT^A04, ADT^A08 or ORU^R01. |
-host, -port | localhost, 2575 | The listener. |
-timeout | 35s | How long to wait to connect, and for each ACK. Longer than the listener's 30-second MLLP_TIMEOUT, so its AE arrives first. |
-rate | 5 | Messages per second for files with several messages. At most 100. |
-new-id | off | Give each message from -file a fresh MSH-10 before it is sent. With -v, prints each old and new control ID. |
-tls | off | Connect with TLS 1.2 or later. |
-ca, -cert, -key, -insecure, -servername | none | TLS trust, client certificate and the name to check. Need -tls. |
-v | off | Also print each raw ACK. |
-version, -h | Print 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.
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| Code | Means |
|---|---|
AA | Accepted. MedHook has the message safely. |
CA | Commit accept, from a listener in msh15 mode. The listener has it. It counts as success, and the line says it is a commit ACK. |
AE | A temporary error. Send it again later. |
AR | Rejected for good. MSA-3 says why. Resending gets the same answer. |
CE | Commit error. Send it again later. |
CR | Commit 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 code | When |
|---|---|
0 | Every message got AA or CA. |
1 | Any 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. |
2 | A 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 typeMSH.10:MSG00001(orcontrol: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.AAmeans 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. ARwith "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-vto 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_PORTis2575by 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-tlsto a plain port, gets no ACK either. - No ACK from
nc, butmllp-sendworks. Yourncclosed the connection when its input ended. Use thesleep 5form 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 -typesends 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-sendconverts them. Withnc, keep thetrcommands 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-timeoutof 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. CheckGET /api/health, then send again.
Reference
- MLLP and ACKs: framing, ACK codes, resends and TLS listeners.
- Triggers: message types, listeners and filters.
- Executions and replay: Messages, Needs action and replay.
- Environment variables:
MLLP_PORTandMLLP_TIMEOUT.