Connecting
URLs, TLS, timeouts, and connection lifecycle.
Connection URLs
The quickest way to configure a client is a connection URL:
new SmppClient({ url: "smpp://systemId:password@smsc.example.com:2775" });
new SmppClient({ url: "ssmpp://smsc.example.com" }); // TLS, port defaults to 3550
new SmppClient("smpp://localhost"); // a bare string works toosmpp://— plain TCP, default port 2775ssmpp://— TLS, default port 3550user:passin the URL become the defaultsystemId/passwordfor binds- URL-encoded characters are decoded (
sec%40ret→sec@ret)
Discrete options override URL parts:
new SmppClient({
url: "smpp://user:pw@example.com",
port: 12775, // wins over the URL
systemId: "other", // wins over the URL user
});TLS
Pass tls: true or full node:tls connect options:
new SmppClient({
host: "smsc.example.com",
port: 3550,
tls: { ca: [fs.readFileSync("smsc-ca.pem")] },
});Certificates are verified by default — unlike the original node-smpp, which silently disabled verification. For self-signed test peers, opt out explicitly:
tls: { rejectUnauthorized: false }Connect and teardown
await client.connect(); // resolves when the transport is ready for a bind
// ...
await client.unbind(); // polite unbind handshake
await client.close(); // graceful FIN; resolves once the socket closed
client.destroy(); // immediate teardownconnect() rejects with SmppTimeoutError after connectTimeoutMs (default 30 s) or
with the underlying socket error (ECONNREFUSED, ENOTFOUND, …).
close() and destroy() are user-initiated: they never trigger the automatic
reconnect. Only unexpected connection loss does — see
Reliability.
Connection state
client.connected; // transport up?
client.sessionState; // "OPEN" | "BOUND_TX" | "BOUND_RX" | "BOUND_TRX" | "UNBOUND" | "CLOSED"Every request also fails fast with SmppClosedError when the client is not connected
(unless a reconnect is in progress — then it waits).