title: HL7V2 HAPI parser exception while receiving data via TCP/IP
body: <p>I'm using the HAPI <strong>hapi-structures-v25</strong> library with version <strong>2.3</strong> to parse HL7v2 message &amp; convert that into FHIR resources. I'm facing a strange issue while receiving and parsing the HL7V2 message using HAPI via TCP listener.</p>
  <blockquote>
  <p>Determine encoding for message. The following is the first 50 chars of the message for reference, although this may not be where the issue is: MSH|^~\&amp;|test|DrJhonDoe|TEST|UNKNOWN|20210216190432||ADT^A01^ADT_A01|60b647d4-b5a5-4fae-a928-d4a3849de3c8|T|2.5</p>
  </blockquote>
  <p>Strange that I'm not getting this error when I'm trying to send this message as a string in main function. I'm getting this error only when I receive the data over TCP/IP to my Java function. I tried sending the HL7 message to my receiving TCP port using Mirth as well external tool &amp; my result is same.</p>
  <p>Here is the sample of my HL7v2 message Im trying to process</p>
  <pre><code>MSH|^~\\&amp;|test|Dr.JhonDoe|TEST|UNKNOWN|20210216190432.7||ADT^A01^ADT_A01|60b647d4b5a54faea928d4a3849de3c8|T|2.5
  EVN||20210216|20210216|
  </code></pre>
  <p>While receiving the data from tcp/ip im converting the byte to string using the UTF-8 charset.</p>
  <pre><code>InputStream in = connection.getInputStream();
  OutputStream out = connection.getOutputStream();
  receivedMessageSize = in.read(receivedByeBuffer);
  String incomingHl7Message = new String(receivedByeBuffer, StandardCharsets.UTF_8);
  </code></pre>
  <p>Im getting the message properly. But not sure why the error comes.</p>