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

SimpleServer after two exceptions it stops managing new connections #11

Open
javieerrubio11 opened this issue Jan 8, 2018 · 0 comments

Comments

@javieerrubio11
Copy link

*Context of the application
There is an initial server that communicates HL7 messages to another server (SHL7), this second server is in charge of communicating the HL7 messages to a web application. Due to the type of communication that HAPI manages, we choose to create an intermediate application (SHL7) whose only task is to receive the messages in a specific IP and port and transform them to an HTTP call (POST) that the web application understands.

Due to the architecture designed to transform the messages, some errors are generated that the SHL7 server must manage. The most common errors are that the HTTP call does not work correctly (Ex: response 500). Here's how these errors are handled:

Message ack;
try {
	if(response != null && response.getStatusLine().getStatusCode() == 204) {
		ack = theMessage.generateACK();
		log.info("CORRECTO: " + ack.toString());
	} else {
		ack = theMessage.generateACK(AcknowledgmentCode.AE, new HL7Exception("There was a problem in the target server!!"));
		log.info("ERROR: " + ack.toString());
	}
} catch (IOException e) {
	throw new ReceivingApplicationException(e);
}
return ack;

*Problem
The problem is that when the SHL7 server has two communications with AcknowledgmentCode.AE or that the transformation code throws an exception (ReceivingApplicationException, Exception, etc), the SHL7 server no longer manages the other communications, it accepts them in the connection queue , but it no longer executes the message transformation code (own class Ex: RadiologiaReceiverApplication). The only solution now is to restart the SHL7 server but I don't like.

The following log is when the new requests arrive to the server and it does not execute the message transformation code:

2017-12-28 12:34:20.388  INFO 1 --- [hapi-worker-1] ca.uhn.hl7v2.app.SimpleServer            : Accepted connection from 167.69.0.110:59237 on local port 4556
2017-12-28 12:34:20.389  INFO 1 --- [hapi-worker-1] u.h.c.RadiologiaConnectionListener       : New connection received: /167.69.0.110
2017-12-28 12:34:30.449  INFO 1 --- [hapi-worker-21] ca.uhn.hl7v2.llp.MllpDecoderState        : End of input stream reached.
2017-12-28 12:34:30.449  INFO 1 --- [hapi-worker-21] ca.uhn.hl7v2.llp.MllpDecoderState        : SocketException on read() attempt.  Socket appears to have been closed: End of input stream reached before message starts
2017-12-28 12:34:30.449  INFO 1 --- [hapi-worker-21] ca.uhn.hl7v2.app.Receiver                : SocketException: closing Connection from 167.69.0.110:59237, will no longer read messages with this Receiver: End of input stream reached before message starts
2017-12-28 12:34:30.896  INFO 1 --- [hapi-worker-2] u.h.c.RadiologiaConnectionListener       : Lost connection from: /167.69.0.110
2017-12-28 12:35:30.860  INFO 1 --- [hapi-worker-1] ca.uhn.hl7v2.app.SimpleServer            : Accepted connection from 167.69.0.110:52502 on local port 4556
2017-12-28 12:35:30.860  INFO 1 --- [hapi-worker-1] u.h.c.RadiologiaConnectionListener       : New connection received: /167.69.0.110
2017-12-28 12:35:40.920  INFO 1 --- [hapi-worker-23] ca.uhn.hl7v2.llp.MllpDecoderState        : End of input stream reached.
2017-12-28 12:35:40.922  INFO 1 --- [hapi-worker-23] ca.uhn.hl7v2.llp.MllpDecoderState        : SocketException on read() attempt.  Socket appears to have been closed: End of input stream reached before message starts
2017-12-28 12:35:40.923  INFO 1 --- [hapi-worker-23] ca.uhn.hl7v2.app.Receiver                : SocketException: closing Connection from 167.69.0.110:52502, will no longer read messages with this Receiver: End of input stream reached before message starts
2017-12-28 12:35:41.410  INFO 1 --- [hapi-worker-2] u.h.c.RadiologiaConnectionListener       : Lost connection from: /167.69.0.110

I do not know if the problem is that the communication socket of the previous connections has not been closed correctly or another problem ... However, I do not know exactly how the HL7Service class manages the connections.

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

1 participant