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

Is there any socket timeout implemented on MLLPClient? #18

Open
aventrax opened this issue Feb 2, 2018 · 4 comments
Open

Is there any socket timeout implemented on MLLPClient? #18

aventrax opened this issue Feb 2, 2018 · 4 comments

Comments

@aventrax
Copy link

aventrax commented Feb 2, 2018

Hello, I'm using this library to perform some health check on a HL7 service that is receiving messages.
The logic is: everything is good if I have back a message (AA or AE doesn't matter), but give me an error if the service does not respond or the answer is not understandable (HL7 standard).
I'm trying to trap the possible errors on the MLLPClient call, and it throws me error if the service's port is closed/firewalled or if the service doesn't respond at all to my send_message .

The problem is: If perform this health check and the server doesn't respond but does not close the socket, the MLLPClient blocks my health check. In other words it seems there is not any timeout implemented.

Is there any chance to have this kind of timeout implemented? I have tried to do it myself, modifying the client.py, but unsuccessfully... Can you help me? Thanks

@aventrax
Copy link
Author

aventrax commented Feb 2, 2018

Checking the communication with Wireshark, I found the message is being sent (by send_message() ) but the server did not anwer and did not close the connection, so it remains opened indefinitely...

I know this is not a normal use case but the library should close the socket if the other side does not, after a period of time... at least in my opinion...

@rvmey
Copy link

rvmey commented May 10, 2021

I have the same problem.

@f4berack
Copy link

f4berack commented May 16, 2021

Hi @aventrax @rvmey ,
the first solution that comes to my mind is to set the socket timeout inside the constructor by adding the code row
self.socket.settimeout() before self.socket.connect((host, port))

According to your experience, what is your desired timeout?

When I can, I'll try to fix this and do some testing.
Let me know if the proposed solution works.

@dmeiser
Copy link

dmeiser commented Oct 7, 2021

In our use case, we're using python-hl7 to send messages. The connection is dropped somewhere and python-hl7 doesn't know that the connection is timed out and the socket is hangs open, blocking other processes. Our desired timeout would be 10s, but I would hope that the configuration option would be exposed for tuning.

Alternatively, would it possible to expose the underlying socket object for advanced use cases?

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

No branches or pull requests

4 participants