TCP - Keeping connections open

When creating TCP connections with HL7 Soup products, the default is to have the client close the connection on every call while the server keeps the connection open. That's because this configuration is the most likely to succeed, no matter what the settings of the external system. It's is possible to detect a closed connection much more efficiently on the server than the client.

However, there are several reasons you may wish to alter this default configuration.

  • There is an OS throughput limitation for this model of ~16,000 messages per 2 minutes. If there is a chance of reaching this limit, then it is recommended that you uncheck "Keep Connection Open" on the TCP Receiver.
  • You may wish to change due to concurrency requirements. Setting both ends to "Keep Connection Open" blocks other systems from slipping messages onto the queue. However, it's worth pointing out that this is not a security feature. Other systems could still acquire the connection during an outage, and this would then block the original connection from re-establishing. For the same reason, testing might be cumbersome.
  • Third-party requirements or limitations may force you to select an option explicitly.

For your assistance, the following compares the different pairing of settings.

Default

This is the default.

Behaviour

The client closes the connection after the message was sent or the response was received. The server can detect this and will create a new socket for each call.

Concurrency

Multiple clients can send messages at the same time.

Limitation

The operating system limits the number of sockets to ~16000 per 2 minutes. Sending more than that to the same port will result in the error "Only one usage of each socket address (protocol/network address/port) is normally permitted".

Behaviour

After the message has been received both the server and client close the connection and prepare for the next one.

Concurrency

Multiple clients can send messages at the same time.

Limitation

If another system calls this with the client keeping it open, then it will error. This isn’t often a problem but is the reason that HL7 Soup doesn’t use this configuration by default.

Behaviour

If the connection is broken it is up to the client to re-establish the connection. The server will detect that the connection was lost and will close and wait for a new one.

Upon a lost connection the first error will be "The server did not respond with a complete message" Followed by repeating "No connection could be made because the target machine actively refused it" until the server becomes accessible.

Concurrency

Only one client can send messages at the same time.

Limitation

No other client will be able to connect until the connection is closed.

Behaviour

Do not do this.

Limitation

The server pulls the plug on the client after the first message. The closed connection is not detected by the client, so the second message gets the error "The server did not respond with a complete message".