use socket.sendall() instead of socket.send()
In a big project I currently encounter the fact, that another software receives just a partial MLLP message.
While debugging this issue I looked at the code of https://github.com/johnpaulett/python-hl7/blob/main/hl7/client.py
Though I'm still not 100% sure, that hl7.client is the culprit in the current scenario I noticed, that
hl7.client.MLLPClient.send()
contains following line:
self.socket.send(data)
reading the documentation of https://docs.python.org/3/library/socket.html#socket.socket.send one can read:
Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data.
This is not done in the code. So perhaps better to use self.socket.sendall(data)
https://docs.python.org/3/library/socket.html#socket.socket.sendall
Unlike send(), this method continues to send data from bytes until either all data has been sent or an error occurs.
@feenes, we might encounter the same issue here. In our case, we saw a 2 HL7 messages sent into one packet because. To be more precise, the first one seems malformed, and probably not recognized as a full message, this could be the reason it gets concatenated with the second. We just started our bug hunt, so our information are still a bit scarce. I'll come backer later on, when I get more details.