IPWorks EDI 2020 Python Edition

Questions / Feedback?

MLLPServer Class

Properties   Methods   Events   Configuration Settings   Errors  

The MLLPServer class implements the server side of the Minimal Lower Layer Protocol.


class ipworksedi.MLLPServer


The MLLPServer class is used to exchange HL7 data with one or more connected MLLP clients.

Setting up MLLPServer to Listen for Client Connections

The first step in using the MLLPServer class is to configure it to listen for MLLP client connections. Start by setting the local_port property to the desired listening port. For multi-homed devices, also set the local_host property to the address of the network interface the MLLPServer class should listen on.

Next, optionally enable TLS/SSL with the ssl_enabled and ssl_cert properties (MLLPServer supports client authentication with the ssl_authenticate_clients property).

Finally, set the listening property to True to begin listening for client connections.

Connecting Example

mllpServer.LocalHost = "localhost";
mllpServer.LocalPort = 7777;

// The following two lines are only necessary if using TLS/SSL.
mllpServer.SSLEnabled = true;
mllpServer.SSLCert = new Certificate(CertStoreTypes.cstPFXFile, "..\\path\\to\\cert.pfx", "password", "*");

mllpServer.Listening = true;

At this point the on_connection_request event will fire anytime a client wishes to connect (connection requests are accepted by default), and the on_connected event will fire each time a client successfully connects.

While clients are connected, the server may interact with them by using their oftp_connection_connection_id to interact with the class's properties.

Receiving Data

The MLLPServer class will automatically receive HL7 data sent from each client, and will automatically send acknowledgements back.

When the MLLPServer class is receiving data, immediately before data transfer begins the on_start_transfer event fires. During data transfer, one or more on_transfer events will fire. When data transfer is complete, the on_end_transfer event fires. Any errors during data delivery will cause the on_error event to fire.

Immediately before the server acknowledgement is sent the on_ack_out event fires. The Accept parameter of this event is used to determine the type of acknowledgement (ACK or NAK) to send back to the client.

HL7 data received by the MLLPServer class will be stored in one of the following ways:

  • If an output file path has been set to the output_filename property, the data is written to that file.
  • Otherwise, the data is stored in the output_data property.

Sending Data

The MLLPServer class may also send data to MLLP clients. First, specify the data to send by doing one of the following:

  • Set the input_filename property to the path of a file with HL7 data.
  • Set the HL7 data directly to the input_data property.

Once the data has been specified, simply call the send method with the appropriate connection Id to send the HL7 data to the associated client. Once the client has received the data, it will respond with an acknowledgement, causing the class's on_ack_in event to fire.

Sending Data Example

mllpServer.Connections[connectionId].InputData = "HL7Data";

Property List

The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

connection_countThe number of records in the arrays.
connectedTriggers a connection or disconnection.
connection_idThe Id of the connection.
input_dataThe raw HL7 data to send.
input_filenameThe path of a file containing HL7 data to send.
local_addressThe address of the local interface through which the connection is passing.
output_dataThe raw HL7 data received.
output_filenameThe path of a file in which to store received HL7 data.
remote_hostThe address of the MLLP client associated with the connection.
remote_portThe port of the MLLP client associated with the connection.
timeoutThe timeout value, in seconds, for the connection.
default_timeoutAn initial timeout value to be used by incoming connections.
keep_aliveWhen True, KEEPALIVE packets are enabled (for long connections).
listeningIf True, the class accepts incoming connections on LocalPort.
local_hostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
local_portThe TCP port in the local host where the class listens.
ssl_authenticate_clientsIf true, the server asks the client(s) for a certificate.
ssl_cert_encodedThe certificate (PEM/base64 encoded).
ssl_cert_storeThe name of the certificate store for the client certificate.
ssl_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
ssl_cert_store_typeThe type of certificate store for this certificate.
ssl_cert_subjectThe subject of the certificate used for client authentication.
ssl_enabledWhether TLS/SSL is enabled.
versionThe MLLP version to use.

Method List

The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

configSets or retrieves a configuration setting.
disconnectDisconnect the specified client.
do_eventsProcesses events from the internal message queue.
interruptInterrupts a synchronous send to the remote host.
resetReset the class.
sendSend HL7 data to the MLLP client associated with the specified connection Id.
shutdownShuts down the server.

Event List

The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_ack_inFires immediately after receiving an acknowledgement from a client.
on_ack_outFires immediately before sending an acknowledgement to a client.
on_connectedFired immediately after a connection completes (or fails).
on_connection_requestFired when a request for connection comes from a remote host.
on_disconnectedFired when a connection is closed.
on_end_transferFires after incoming HL7 data finishes transferring.
on_errorInformation about errors during data delivery.
on_logProvides logging information.
on_ssl_client_authenticationFired when the client presents its credentials to the server.
on_ssl_connection_requestFires when an SSL connection is requested.
on_ssl_statusShows the progress of the secure connection.
on_start_transferFires before incoming HL7 data begins transferring.
on_transferFires during incoming data transfer.

Configuration Settings

The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

ACKCharThe positive acknowledgement character.
EndBlockCharThe character that denotes the end of HL7 data.
EOLCharThe character that denotes the end of a message block.
LogLevelThe level of detail that is logged.
NAKCharThe negative acknowledgement character.
ReceiveTimeoutMaximum number of seconds to wait after receiving a StartBlockChar.
StartBlockCharThe character that denotes the beginning of HL7 data.
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the class whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe port in the local host where the class binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
ProxyExceptionsListA semicolon separated list of hosts and IPs to bypass when using a proxy.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
TcpNoDelayWhether or not to delay when sending packets.
UseIPv6Whether to use IPv6.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCACertFilePathsThe paths to CA certificate files on Unix/Linux.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLCheckCRLWhether to check the Certificate Revocation List for the server certificate.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLEnableRenegotiationWhether the renegotiation_info SSL extension is supported.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLNegotiatedCipherReturns the negotiated ciphersuite.
SSLNegotiatedCipherStrengthReturns the negotiated ciphersuite strength.
SSLNegotiatedCipherSuiteReturns the negotiated ciphersuite.
SSLNegotiatedKeyExchangeReturns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrengthReturns the negotiated key exchange algorithm strength.
SSLNegotiatedProtocolReturns the negotiated protocol version.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLServerCACertsA newline separated list of CA certificate to use during SSL server certificate validation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks EDI 2020 Python Edition - Version 20.0 [Build 8162]