Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use socket.sendall() instead of socket.send() #41

Open
feenes opened this issue Nov 5, 2021 · 1 comment · May be fixed by #50
Open

use socket.sendall() instead of socket.send() #41

feenes opened this issue Nov 5, 2021 · 1 comment · May be fixed by #50

Comments

@feenes
Copy link

feenes commented Nov 5, 2021

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.
@Stanislasss
Copy link

@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.

NiklasMM added a commit to mps-gmbh/python-hl7 that referenced this issue Nov 30, 2022
@NiklasMM NiklasMM linked a pull request Nov 30, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants