txHL7 icon indicating copy to clipboard operation
txHL7 copied to clipboard

handleMessage() always sends a response

Open corydodt opened this issue 11 years ago • 4 comments

MLLP doesn't require a response to be sent to an ACK. If you set up two instances of twisted-hl7 talking to each other, each one will ACK the other's ACKs, resulting in an infinite loop.

Moreover, the API doesn't provide a way to implement this.

In dataReceived's enclosed function onSuccess(), simply capture a False result of some kind. If handleMessage returns None or '', onSuccess does nothing. Then, ACK can be handled by returning None.

corydodt avatar Sep 03 '14 21:09 corydodt

https://github.com/johnpaulett/twisted-hl7/pull/6/files

corydodt avatar Sep 23 '14 01:09 corydodt

@corydodt Thanks!

I'm ok merging this PR if you add some test coverage.

Alternatively, perhaps instead of using a inner function of for onSuccess, we can make the Receiver define it's onSuccess management strategy (I haven't thought through exactly how to do this so perhaps it is not ideal).

johnpaulett avatar Oct 14 '14 22:10 johnpaulett

Sounds good. I'll keep the scope as-is (inner function) for now, and add test coverage.

Thanks!

corydodt avatar Oct 14 '14 22:10 corydodt

This should be fixed by this commit https://github.com/johnpaulett/twisted-hl7/commit/cde15f6ff50ae4e9c077d3edf4a3641252897c01#diff-645924d0286b5e86921ce11a152fb37aL101

writeMessage now checks if message is None and does nothing, so your receivers handleMessage can return None to stop the loop.

rectalogic avatar Oct 23 '14 16:10 rectalogic