SMPP: sending massage via SMPP javascript

  encoding, javascript, node.js, protocols, smpp

I am trying to send message using SMPP in node.js

I wrote the code to send message below, It told me that "successfully bound", but the message was not sent.

Can anyone help me what I need to add or delete?

And, I would like to send bulk message as well using SMPP

Anyone can help me for it as well?

The bind is required for this message should be below:

Server Ip: – api.xxxxx.com

Port: – 2350

User Name: – xxxxxx

Password: – xxxxx

Enquire Link Interval:-180

Source TON: – 0

Source NPI: – 1

Destination TON: – 1

Destination NPI: – 1

Data Coding: – (Use only 0 for Plain Text messaging, 8 for Unicode and any other value only for exceptional cases)

Thanks guys!


const session = smpp.connect(given api, 2345);

let isConnected = false;

session.on('connect', () => {

  isConnected = true;

  session.bind_transceiver({
    system_id: 'system_id',
    password: 'system_password',
    Enquire_interval: 180,
    source_ton: 0,
    source_npi: 1,
    addr_ton: 1,
    addr_npi: 1,
    data_code: 8,
  }, (pdu) => {
    if (pdu.command_status == 0) {
      console.log('Successfully bound');
    }
  })
})
session.on('close', () => {
  console.log('smpp is now disconnected');
  if (isConnected) {        
    session.connect();    //reconnect again
  }
})
session.on('error', error => { 
  console.log('smpp error', error)   
  isConnected = false;
});

function sendSMS(from, to, text) {
  from = `+${from}`; 
 // this is very important so make sure you have included + sign before ISD code to send sms
  to = `+${to}`;
  session.submit_sm({
    source_addr: from,
    destination_addr: to,
    short_message: text
  }, function(pdu) {
    if (pdu.command_status == 0) {
        // Message successfully sent
        console.log(pdu.message_id);
    }
  });
}

sendSMS(12345, 12345, 'Hello');```

Source: Ask Javascript Questions

LEAVE A COMMENT