HL7 v2 & integration
MLLP and acknowledgments
How v2 messages travel over TCP, and how the receiver confirms each one.
Framing#
v2 travels over a plain TCP socket using the Minimal Lower Layer Protocol. Each message is wrapped in three control bytes:
<VT> message segments separated by <CR> <FS><CR>
0x0B 0x1C 0x0DThat's all there is to MLLP. There's no TLS and no authentication, which is why MLLP stays on trusted networks (or inside a VPN). In this lab the MLLP ports (6661–6670) are LAN only.
Acknowledgments (ACK)#
For every message, the receiver returns an ACK carrying the original control id:
MSH|^~\&|OIE|LAB|FHIRLAB|SYNTHEA|20261126101501||ACK^A04^ACK|ACK123|P|2.5
MSA|AA|MSG20261126101500123| MSA-1 | Meaning | What the sender should do |
|---|---|---|
AA |
Application Accept | Move on to the next message |
AE |
Application Error | The message was understood but couldn't be processed. Raise an alert; don't just resend it |
AR |
Application Reject | The message was malformed or not allowed. Fix it at the source |
CA / CE / CR are the "commit" versions used in enhanced mode. You'll rarely see them.
Ordering and retries#
Most v2 feeds are ordered: an A08 must not overtake the A04 it updates. Senders therefore wait for each ACK before sending the next message. That's also why a single slow or failing message can block a whole feed. Watch queue depth in the engine dashboard.
Test with nothing but netcat#
printf '\x0bMSH|^~\\&|TEST|LAB|OIE|LAB|20261126||ADT^A04^ADT_A01|T1|P|2.5\rPID|1||X1^^^TEST^MR||Test^Net\r\x1c\x0d' \
| nc -q 3 192.168.1.181 6661 | tr '\r' '\n'If you get no ACK, the channel isn't deployed or isn't listening; see Troubleshooting.