better-smpp
Client

Binding

bind_transmitter, bind_receiver, bind_transceiver — and what happens on failure.

After connecting, a session must bind before exchanging messages. SMPP has three flavors:

MethodWire commandGrants
bindTransmitter()bind_transmittersubmit only
bindReceiver()bind_receiverreceive deliveries only
bindTransceiver()bind_transceiverboth directions
await client.connect();
const resp = await client.bindTransceiver();
client.sessionState; // "BOUND_TRX"

Credentials and parameters

Bind parameters fall back to the client options (and the URL's user:pass), so most apps bind with no arguments. Everything can be overridden per call:

await client.bindTransceiver({
  systemId: "ESME01",
  password: "secret",
  systemType: "SMPP",
  interfaceVersion: 0x50, // default; use 0x34 for strict v3.4 peers
  addrTon: 1,
  addrNpi: 1,
  addressRange: "467*",
});

If the SMSC reports its own interface version via the scInterfaceVersion TLV in the bind response, it's exposed as:

client.smscInterfaceVersion; // e.g. 0x50

Failure handling

A rejected bind rejects the Promise with SmppCommandError carrying the status and the full response PDU — no response-object inspection needed:

import { CommandStatus, SmppCommandError } from "@better-smpp/core";

try {
  await client.bindTransceiver();
} catch (error) {
  if (error instanceof SmppCommandError) {
    error.commandStatus;     // 0x000d
    error.commandStatusName; // "ESME_RBINDFAIL"
  }
}

The session stays OPEN after a failed bind — you can retry with different credentials or close().

Unbinding

await client.unbind(); // sends unbind, awaits unbind_resp
client.sessionState;   // "UNBOUND"
await client.close();

The bound and unbound events fire on every transition, including automatic rebinds performed by the reconnect machinery.

On this page