Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where DO I Need To Set Short Code #64

Closed
HemanParbhakar opened this issue May 16, 2017 · 25 comments
Closed

Where DO I Need To Set Short Code #64

HemanParbhakar opened this issue May 16, 2017 · 25 comments

Comments

@HemanParbhakar
Copy link

Can You Please Help me Where we need to set short code

@ritmas
Copy link
Contributor

ritmas commented May 16, 2017

I believe you have in mind sender value which is set as source_addr:

session.submit_sm({
destination_addr: '<phone_number>',
source_addr: '<sender/shortcode>',
short_message: '<SMS_body>'
});

@HemanParbhakar
Copy link
Author

var smpp = require('smpp');
var server = smpp.createServer(function(session) {
session.on('bind_transceiver', function(pdu) {
// we pause the session to prevent further incoming pdu events,
// untill we authorize the session with some async operation.
session.pause();
checkAsyncUserPass(pdu.system_id, pdu.password, function(err) {
if (err) {
session.send(pdu.response({
command_status: smpp.ESME_RBINDFAIL
}));
session.close();
return;
}
session.send(pdu.response());
session.resume();
});
});
});
server.listen(2775);

// Using This to create server please Hellp

Getting Error Of checkAsyncUserPass is not defined

@ritmas
Copy link
Contributor

ritmas commented May 16, 2017

It's not clear in this code snippet whether you have defined such function checkAsyncUserPass

@HemanParbhakar
Copy link
Author

i have copy this fuction from README and there was exact the same

@ritmas
Copy link
Contributor

ritmas commented May 16, 2017

This example is quite old and misleading. My suggestion is not to use checkAsyncUserPass() and do your own actions as successful bind_transceiver callback is all what you need - once it's fired up, you may send/receive messages.

@HemanParbhakar
Copy link
Author

ok Thankss And Can Transeceiver set to be multiple Connection at same time

@ritmas
Copy link
Contributor

ritmas commented May 16, 2017

Well transceiver mode is dedicated for bidirectional communication, which means the same session supports both transmitter (sending messages) & receiver (receiving messages) modes. In other words, you don't have to initiate two connections at the same time to fully support communication with SMSC.

It's enough to maintain single session with SMSC for sending multiple messages and handling received ones at the same time. But if you want to handle multiple sessions to the same SMSC make sure SMSC configuration allows you to do that. In most cases, it should be restricted to 1-2 sessions only with different TPS, etc.

@HemanParbhakar
Copy link
Author

as My Connection is always open using node server.js . But At Same TIme How Can I Send Message

@ritmas
Copy link
Contributor

ritmas commented May 16, 2017

It's given in README as an example, you need to use session.submit_sm();

@HemanParbhakar
Copy link
Author

HemanParbhakar commented May 16, 2017

but the sms number and message are dynamic as it would be send by android
how can i send SMS then

@HemanParbhakar
Copy link
Author

When I Get message Id that means Message has been Sent

@ritmas
Copy link
Contributor

ritmas commented May 19, 2017

Not really. It means SMSC has accepted your request to send message. Later SMSC will notify you whether SMS has been successfully sent to user or not - that's delivery report. You should handle it upon received PDU with:

session.on('deliver_sm', function(pdu) {
   // parse/handle PDU
   session.send(pdu.response());
});

PDU example of deliveyr report is:

{
    command_length: 144,
    command_id: 5,
    command_status: 0,
    sequence_number: 33576672,
    command: 'deliver_sm',
    service_type: '',
    source_addr_ton: 1,
    source_addr_npi: 1,
    source_addr: '<phone>',
    dest_addr_ton: 2,
    dest_addr_npi: 1,
    destination_addr: '<schortcode>',
    esm_class: 4,
    protocol_id: 0,
    priority_flag: 0,
    schedule_delivery_time: '',
    validity_period: '',
    registered_delivery: 0,
    replace_if_present_flag: 0,
    data_coding: 0,
    sm_default_msg_id: 0,
    short_message: {
        message:'id:37bc0c3 sub:001 dlvrd:000 submit date:1705190504 done date:1705190504 stat:DELIVRD err:000'
    }
}

Here stat:DELIVRD indicates SMS has successfully reached destination.

@HemanParbhakar
Copy link
Author

Means i have to Implement this on Reciever

@MukitCSTE
Copy link

MukitCSTE commented Mar 12, 2018

How to send

SMSC --> ESME

i mean can i work like this

session.deliver_sm({
command_length: 144,
command_id: 5,
command_status: 0,
sequence_number: 33576672,
command: 'deliver_sm',
service_type: '',
source_addr_ton: 1,
source_addr_npi: 1,
source_addr: 'Custom SMPP Service',
dest_addr_ton: 2,
dest_addr_npi: 1,
destination_addr: 'Client',
esm_class: 4,
protocol_id: 0,
priority_flag: 0,
schedule_delivery_time: '',
validity_period: '',
registered_delivery: 0,
replace_if_present_flag: 0,
data_coding: 0,
sm_default_msg_id: 0,
short_message: {
message:'id:123 sub:001 dlvrd:000 submit date:1705190504 done date:1705190504 stat:DELIVRD err:000'
}
}, function(pdu) {
if (pdu.command_status == 0) {
// Message successfully sent

			console.log('The Delivary report  is  successfully sent');
		}
	});

@MukitCSTE
Copy link

session.deliver_sm it's working finally . Thanks to all :)

@Kindlysertir
Copy link

So, how can i does cuz i have this error :

checkAsyncUserPass('wavesmpp1', 'wavesmp1', function(err) {
^

ReferenceError: checkAsyncUserPass is not defined
at Session. (/root/smppserver.js:7:9)
at emitOne (events.js:96:13)
at Session.emit (events.js:188:7)
at Session.extractPDUs (/root/node_modules/smpp/lib/smpp.js:67:8)
at emitNone (events.js:86:13)
at Socket.emit (events.js:185:7)
at emitReadable
(_stream_readable.js:432:10)
at emitReadable (_stream_readable.js:426:7)
at readableAddChunk (_stream_readable.js:187:13)
at Socket.Readable.push (_stream_readable.js:134:10)

@Kindlysertir
Copy link

The checkAsyncUserPass is not defined for me.
Please i need a help !

@ritmas
Copy link
Contributor

ritmas commented Jan 31, 2019

checkAsyncUserPass() is custom function, you can define it by yourself:

function checkAsyncUserPass(system_id, password, callback) {
    if (system_id === 'wavesmpp1' && password === 'wavesmp1') {
        callback(0); // no error
    } else {
        callback(1); // error
    }
}

@Kindlysertir
Copy link

Kindlysertir commented Jan 31, 2019

checkAsyncUserPass() is custom function, you can define it by yourself:

function checkAsyncUserPass(system_id, password, callback) {
    if (system_id === 'wavesmpp1' && password === 'wavesmp1') {
        callback(0); // no error
    } else {
        callback(1); // error
    }
}

Ok, thanks. But now i gat the error like :

Error: Cannot find module 'smpp'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object. (/root/smppserver.js:1:74)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)

@ritmas
Copy link
Contributor

ritmas commented Jan 31, 2019

function checkAsyncUserPass(pdu.system_id, pdu.password, function(err) {

You've defined function parameters as pdu object properties, but I assume you're passing them as variables. Double check on the code itself on how you're calling checkAsyncUserPass().

@Kindlysertir
Copy link

function checkAsyncUserPass(pdu.system_id, pdu.password, function(err) {

You've defined function parameters as pdu object properties, but I assume you're passing them as variables. Double check on the code itself on how you're calling checkAsyncUserPass().

The error is : Error: Cannot find module 'smpp'

Please how can i fixe it ?

@Kindlysertir
Copy link

I install smpp like : npm install smpp it work. Thanks !

@Kindlysertir
Copy link

But i can not connect to it.

@juliangut
Copy link
Collaborator

@Kindlysertir have you required the module in the code?

var smpp = require('smpp');

@juliangut
Copy link
Collaborator

It's been almost 3 months since last answer, I assume we can close this issue. Feel free to comment again if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants