Function: isTlsProtocolError()
isTlsProtocolError(
err):boolean
Detects TLS-protocol-shaped errors, failures of the TLS protocol itself, as opposed to plain TCP-level network failures.
Apply this only to errors raised on a TLS connection; MllpClient
does exactly that (the predicate is consulted only when ClientOptions.tls
is set). The boundary:
TLS-protocol-shaped (true):
codestartingERR_SSL_(Node's TLS alert codes, e.g.ERR_SSL_TLSV13_ALERT_CERTIFICATE_REQUIRED, aclientAuth: 'MUST'server rejecting the client's certificate).code === 'EPROTO', on a TLS connection this is OpenSSL failing the handshake (protocol version mismatch, no shared cipher, a TLS ≤1.2 mTLS rejection).messagecontainingssloralert(/\bssl\b|\balert\b/i, "SSL routines", "tlsv13 alert certificate required", …). This message check is a heuristic backstop over the code-based checks above, not a precise boundary: it exists to catch OpenSSL errors that surface without a usablecode, andMllpClientconsults it only on connections where TLS is configured. An arbitrary non-TLS error whose message happens to contain those words would also match.
NOT TLS-protocol-shaped (false), plain network failures, which stay
transient for the reconnect classifier: ECONNREFUSED, ETIMEDOUT,
EHOSTUNREACH, ENETUNREACH, EPIPE, and a plain ECONNRESET carrying
no TLS alert context, a network blip during (or after) a handshake
should still auto-heal.
Certificate-verification failures are a separate class, see
isTlsVerificationErrorCode; MllpClient checks that first and
labels those connectionCause: 'tls-verify'.
Why this matters: under TLS 1.3 (RFC 8446 §4.4.2) a clientAuth: 'MUST'
server can reject the client's certificate AFTER the client's own
'secureConnect', the rejection then surfaces as a post-connect socket
error. A misconfigured mTLS client must never auto-reconnect-loop against
a server that will always reject it, so MllpClient classifies
TLS-protocol-shaped errors as permanent.
Parameters
err
unknown
Returns
boolean
Example
import { isTlsProtocolError, MllpConnectionError } from '@cosyte/mllp';
client.on('error', ({ error }) => {
if (error instanceof MllpConnectionError && isTlsProtocolError(error.cause)) {
// TLS protocol failure, a configuration problem, not a network blip.
}
});