Tuesday, 11 April 2017

unable to receive sms in node smpp

I can send sms using Node SMPP but i am unable to receive sms back on my system .please have a look at my code. waiting for reply....

var smpp = require('smpp');

try{

    var session = smpp.connect('smpp.server.com',5698);

    session.bind_transceiver({

        system_id: 'username',

        password: 'password'

    }, function(pdu){

        console.log('server is litening1');

        console.log("Before receive: ",pdu);

        session.on('pdu', function(pdu){

            console.log("inside session.on: ", pdu);

            if (pdu.command == 'deliver_sm') {

                var fromNumber = pdu.source_addr.toString();

                var toNumber = pdu.destination_addr.toString();

                var text = '';
                if (pdu.short_message && pdu.short_message.message) {

                    text = pdu.short_message.message;
                }
                //console.log(console.log());       

                console.log('SMS ' + from + ' -> ' + to + ': ' + text);

                // Reply to SMSC that we received and processed the SMS

                session.deliver_sm_resp({ sequence_number: pdu.sequence_number });

            }

            else{

                console.log("Error: ", pdu);
            }

        });

    });

}

catch(ex){

    //console.log('Error12: ',ex);

}

any help will be appreciated.



via Tayyab Hussain

No comments:

Post a Comment