farhadi / node-smpp

SMPP client and server implementation in node.js
MIT License
417 stars 177 forks source link

Getting invalid password response from SMPP Server #235

Closed elhananjair closed 1 year ago

elhananjair commented 1 year ago

Greetings, I am trying to play with this nodejs SMPP package, here is my code:

var smpp = require('smpp');
var session = smpp.connect({
        url: 'smpp://HOST_NAME:PORT',
        auto_enquire_link_period: 10000,
        debug: true
}, function() {
        session.bind_transceiver({
                system_id: 'ID',
                password: 'PASS', //a password containing 8 characters including number, letter, and symbols
                interface_version: '0x34'  //I tried without specifying this but the result is the same
        }, function(pdu) {
                if (pdu.command_status === 0) {
                        // Successfully bound
                       console.log("Successfully Created Bound");
                }else if(pdu.command_status === 14){  
                      console.log("Invalid Password");
                }
        });
});

session.on('deliver_sm', (pdu) => {
    const { short_message, destination_addr, esm_class} = pdu;
    if(esm_class !== 4 && short_message.message === 'ok') { //Indicates Message Type and enhanced network services, if it's 4 then it's a delivery receipt if not in this case it is a sms message sent from SMSC
        console.log("Received SMS");
    }
    console.log("PDU IS : " + pdu);
})

session.on('error', (e) => {
    if(e.code === 'ETIMEOUT') {
        console.log("Connection to SMS-C Timeout");
    }else if(e.code === 'ECONNREFUSED'){
        console.log("Connection to SMS-C Refused")
    }else if(e.code === 'EAI_AGAIN'){
        console.log("Connection to internet is lost!");
    }else {
        console.log(`There is something wrong connecting to SMS-C, Error code: ${e.code}` );
    }
})

I am assuming command status 14 is for an invalid password as specified on SMPP Spec. But I couldn't understand how can that be possible, here is the out put of running the index.js file

2023-07-15T23:20:51.533Z - cli - 840951 - server.connected - connected to server - {"secure":false} - [HOSTNAME]
2023-07-15T23:20:51.536Z - cli - 840951 - pdu.command.out - bind_transceiver - {"command":"bind_transceiver","command_length":0,"command_id":9,"command_status":0,"sequence_number":1,"system_id":"ID","password":"PASS","system_type":"","interface_version":"0x34","addr_ton":0,"addr_npi":0,"address_range":""} - [HOST_NAME]
2023-07-15T23:20:51.538Z - cli - 840951 - socket.data.out -  - {"bytes":37} - [HOST_NAME]
2023-07-15T23:20:51.550Z - cli - 840951 - socket.data.in -  - {"bytes":23} - [HOST_NAME]
2023-07-15T23:20:51.551Z - cli - 840951 - pdu.command.in - bind_transceiver_resp - {"command_length":23,"command_id":2147483657,"command_status":14,"sequence_number":1,"command":"bind_transceiver_resp","system_id":"ID"} - [HOST_NAME]
Invalid Password
2023-07-15T23:20:51.554Z - cli - 840951 - server.disconnected - disconnected from server -  - [HOST_NAME]
elhananjair commented 1 year ago

The problem was an incorrect password but I am confused why the response is 14 instead of 13 which implies an incorrect password. Anyways I am happy that it is just an incorrect password.