Skip to content

Commit 387da17

Browse files
committed
Added perftest.js script & other minor updates
1 parent 8a5891d commit 387da17

File tree

6 files changed

+178
-48
lines changed

6 files changed

+178
-48
lines changed

Diff for: README.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ cd /smpp-client-nodejs/
2828

2929
# npm install
3030

31-
# npm install system-sleep
32-
3331
```
3432

35-
- Open send.js in your text-editor and add your SMPP host,port, username, password.
33+
- Open send.js in your text-editor and add configure your
34+
- SMPP host,port
35+
- SMPP system_id, password
36+
- Destination Number
37+
- Sender ID (src_address)
38+
- Message body (short_message or message_payload)
3639

3740

3841
- Send SMS
@@ -43,7 +46,7 @@ cd /smpp-client-nodejs/
4346

4447
```
4548

46-
### SMPP Stress Test Client
49+
### Using SMPP Stress Test Client
4750

4851
```shell
4952

@@ -79,6 +82,11 @@ const sleep_time = 1/req_sec_limit*1000; // Sleep time / Wait for x secs
7982

8083
```
8184

85+
### Using Perftest (recommended)
86+
87+
Open perftest.js in your code editor and configure SMPP HOST, PORT, USER, PASS, MESSAGES COUNT & send
88+
89+
8290

8391

8492
### Using this SendViber.js script to send a message to Viber user
@@ -97,6 +105,10 @@ If you have done that already, you may send a test message to a viber phone numb
97105

98106
If you're stuck please open a github issue (https://github.com/telecomsxchange/smpp-client-nodejs/issues )
99107

100-
If you're a TCXC member (Paying subscriber) you may open a trouble ticket by emailing [email protected]
108+
If you're a TCXC member you can open a trouble ticket by emailing [email protected]
109+
110+
### Contribuations
111+
112+
Please create a pull request to submit your contrubuations back with the community. Thank you
101113

102114

Diff for: SendViber.JS

+35-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// This software is released under the MIT license. See the LICENSE file for more information.
2+
// Telecom XChange LLC Copy Right: (c) 2019-2022, Ameed Jamous. All rights reserved.
3+
// License: MIT (It's free to use, modify and distribute.)
4+
// Version: 1.0.0
5+
// Last updated:(Last Updated: 2020-06-22)
6+
// Description: Send SMS using SMPP protocol using node.js.
7+
// Github Repository: https://github.com/telecomsxchange/smpp-client-nodejs.git
8+
// Warranty: No warranty is provided. The software is provided "as is".
9+
// --------------------------------------------------------------------------------------------------------------------
10+
11+
12+
113
//const nanoid = require('nanoid')
214

315
var { nanoid } = require("nanoid");
@@ -14,15 +26,16 @@ smpp.addTLV('billing_price', {
1426
type: smpp.types.tlv.string
1527
});
1628

17-
// Parse Billed Message Counts (Segments) if more than one.
29+
30+
31+
//Parse the count of messages from TCXC SMPP proxy and dsiplaye it in the response. This is only useful when sending towards TelecomsXchange SMSC,
1832

1933
smpp.addTLV('billed_msgs_cnt', {
2034
id: 0x1521,
2135
type: smpp.types.tlv.string
2236
});
2337

24-
25-
// Viber TLVs on TCXC SMPP Proxy :
38+
// Viber TLVs on TCXC smpp proxy:
2639

2740
smpp.addTLV('viber_text', {
2841
id: 0x146A,
@@ -34,6 +47,7 @@ smpp.addTLV('viber_button_cta', {
3447
type: smpp.types.tlv.string
3548
});
3649

50+
3751
smpp.addTLV('viber_button_text', {
3852
id: 0x146C,
3953
type: smpp.types.tlv.string
@@ -53,8 +67,8 @@ smpp.addTLV('viber_failover_step', {
5367
// SMPP AUTHENTICATION DETAILS
5468

5569
session.bind_transceiver({
56-
system_id: 'SMPP USER',
57-
password: 'SMPP PASSWORD'
70+
system_id: 'SMPP USER', // SMPP USER ID
71+
password: 'SMPP PASSWORD' // SMPP PASSWORD
5872
}, function(pdu) {
5973
if (pdu.command_status == 0) {
6074

@@ -63,11 +77,11 @@ session.bind_transceiver({
6377
destination_addr: '123456789', // Viber User Phone Number
6478
source_addr: '19540000000', // Your Phone number
6579
registered_delivery: 1,
66-
message_id: ID,
80+
message_id: ID, // Message ID
6781
viber_text: 'Hello World - Your code is ', // Viber text - Title
6882
viber_button_cta: 'https://google.com', // URL - Hyperlink
6983
viber_button_text: 'Click Here', // Show Button
70-
viber_image_url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Tom_Hanks_2016.jpg/220px-Tom_Hanks_2016.jpg', // Media URL
84+
viber_image_url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Tom_Hanks_2016.jpg/220px-Tom_Hanks_2016.jpg', // Media URL
7185
short_message: 'Hello World, Your code is' + ID, // Body of your message
7286

7387

@@ -81,7 +95,9 @@ session.bind_transceiver({
8195
console.log("SOMETHING HAPPENNED:",pdu);
8296
});
8397

84-
session.on('deliver_sm', function(pdu) {
98+
99+
100+
session.on('deliver_sm', function(pdu) {
85101
console.log(pdu)
86102
if (pdu.esm_class == 4) {
87103
var shortMessage = pdu.short_message;
@@ -90,9 +106,20 @@ session.bind_transceiver({
90106
}
91107
});
92108

109+
//session.send(pdu.response());
110+
93111
session.on('pdu', function(pdu) {
94112
console.log("GOT PDU ", pdu)
95113
});
96114

97115
}
98116
});
117+
118+
// exit the process on ctrl+c
119+
process.on('SIGINT', function() {
120+
session.unbind(function() {
121+
process.exit(0);
122+
});
123+
}
124+
);
125+

Diff for: package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "smpp",
33
"version": "1.0.0",
4-
"description": "NodeJS SMPP Client",
4+
"description": "Several useful NodeJS SMPP Clients for sending single or bulk messages using nodejs",
55
"main": "proxy.js",
66
"dependencies": {
77
"nanoid": "^3.1.16",
@@ -18,7 +18,9 @@
1818
},
1919
"scripts": {
2020
"test": "echo \"Error: no test specified\" && exit 1"
21+
2122
},
22-
"author": "TelecomXChange LLC",
23-
"license": "ISC"
23+
"author": "TelecomXChange LLC - Ameed Jamous",
24+
"license": "MIT"
25+
2426
}

Diff for: perftest.js

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This software is released under the MIT license. See the LICENSE file for more information.
2+
// Telecom XChange LLC Copy Right: (c) 2019-2022, Ameed Jamous. All rights reserved.
3+
// License: MIT (It's free to use, modify and distribute.)
4+
// Version: 1.0.0
5+
// Release Date: 2022-06-22 (Last Updated: 2020-06-22)
6+
// Description: Perfomance test for SMPP protocol using node.js.
7+
// Github Repository: https://github.com/telecomsxchange/smpp-client-nodejs.git
8+
// Warranty: No warranty is provided. The software is provided "as is".
9+
// --------------------------------------------------------------------------------------------------------------------
10+
11+
12+
// Using https://github.com/farhadi/node-smpp (SMPP client library)
13+
14+
var smpp = require('smpp'); // SMPP client library
15+
16+
// Configure SMPP host and port - replace with your own host and port values
17+
18+
var session = smpp.connect('smpp://staging.telecomsxchange.com:2776');
19+
20+
// Configure SMPP session
21+
22+
var { nanoid } = require("nanoid");
23+
var ID = nanoid(10);
24+
session.bind_transceiver({
25+
26+
system_id: 'User', // Insert your SMPP server System_ID
27+
password: 'password' // Insert your SMPP server password
28+
29+
}, function(pdu) {
30+
if (pdu.command_status == 0) {
31+
32+
// Configure SMS message to be sent to SMPP server and send it. In this example its set to send 1000 SMS messages to the destination number 19542400000.
33+
console.log(process.hrtime());
34+
for (ii = 0; ii < 1000; ii++ ) {
35+
// Successfully bound
36+
session.submit_sm({
37+
destination_addr: '19542400000', // Insert your destination number
38+
source_addr: 'Google', // Insert your source number (sender id)
39+
registered_delivery: 1, // Set registered delivery (0 = no, 1 = yes)
40+
short_message: 'Your verification code is G-' + ID +ii // Insert your message content
41+
}, function(pdu) {
42+
if (pdu.command_status == 0) {
43+
// Message successfully sent
44+
console.log("message sent OK", process.hrtime() );
45+
} else {
46+
console.time('sendingFailed' ); // Message sending failed
47+
console.log("message sending failed"); // Message sending failed
48+
}
49+
//console.log(pdu);
50+
});
51+
}
52+
53+
// Handle Delivery Receipts (DR) from SMPP server (if enabled) and print them to the console.
54+
55+
session.on('deliver_sm', function(pdu) {
56+
console.time(pdu)
57+
console._times.clear(); // clear warning
58+
console.log('delivered', pdu.short_message); // print delivered + DLR receipt
59+
//console.log("delivered...")
60+
61+
62+
63+
if (pdu.esm_class == 4) { // Check if message is a delivery receipt
64+
var shortMessage = pdu.short_message; // Get message content
65+
//console.time('Received DR: %s', shortMessage);
66+
session.send(pdu.response()); // Send response to SMPP server
67+
68+
}
69+
70+
71+
});
72+
73+
74+
}
75+
76+
});
77+

Diff for: send.js

+31-30
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
/*
2-
* Copyright (c) 2020 TelecomXChange LLC - https://www.telecomsxchange.com
3-
* All rights reserved.
4-
*/
1+
// This software is released under the MIT license. See the LICENSE file for more information.
2+
// Telecom XChange LLC Copy Right: (c) 2019-2022, Ameed Jamous. All rights reserved.
3+
// License: MIT (It's free to use, modify and distribute.)
4+
// Version: 1.0.0
5+
// Release Date: 2022-06-22 (Last Updated: 2020-06-22)
6+
// Description: Send SMS using SMPP protocol using node.js.
7+
// Github Repository: https://github.com/telecomsxchange/smpp-client-nodejs.git
8+
// Warranty: No warranty is provided. The software is provided "as is".
9+
// --------------------------------------------------------------------------------------------------------------------
510

611
//const nanoid = require('nanoid')
712

813
var { nanoid } = require("nanoid");
914
var ID = nanoid(24);
1015

16+
// Use https://github.com/farhadi/node-smpp (SMPP client library)
17+
1118
var smpp = require("smpp");
1219

1320
// SMPP Host (Destination SMSC server you want to connect to)
1421

1522
var session = smpp.connect("smpp://smpp01.telecomsxchange.com:2776"); // PROD SMSC
1623

17-
// PRODUCTION SMPP URL
18-
19-
//var session = smpp.connect('smpp://staging.telecomsxchange.com:2776'); // Staging SMSC
20-
21-
// CUSTOM TLV PARSING
22-
// Parse the price per message from TCXC SMPP proxy and displayed it in the response.
24+
// CUSTOM TLV PARSING, Parse the price per message from TCXC SMSC and displayed it in the response.
2325

2426
smpp.addTLV("billing_price", {
2527
id: 0x1520,
@@ -45,43 +47,42 @@ session.bind_transceiver(
4547
session.submit_sm(
4648
{
4749
destination_addr: "12345678911", // The destination phone number you want to send a message to
48-
source_addr_ton:5,
49-
source_addr_npi:0,
50-
dest_addr_ton:1,
51-
dest_addr_npi:1,
52-
//source_addr: 'Google', // The Sender ID or Address, This will be displayed to the destination phone number
53-
54-
source_addr: "Alert",
55-
registered_delivery: 1,
56-
message_id: ID,
50+
source_addr_ton: 5, // Type of number of the source address
51+
source_addr_npi: 0, // 0 = Unknown, 1 = ISDN, 3 = Data, 4 = Telex, 5 = SMS, 6 = Radio, 7 = Fax, 8 = Videotelephony
52+
dest_addr_ton: 1, // Type of number of the destination phone number
53+
dest_addr_npi: 1, // 0 = Unknown, 1 = ISDN, 3 = Data, 4 = Telex, 5 = SMS, 6 = Radio, 7 = Fax, 8 = Videotelephony
54+
source_addr: 'Google', // The Sender ID or Address, This will be displayed to the destination phone number
55+
registered_delivery: 1, // Set registered delivery (0 = no, 1 = yes)
56+
message_id: ID, // Message ID
5757
short_message: "Your verification code is " + ID, // The message body, Replace it with the message you want to send.
5858

5959
//message_payload: 'Optional message payload supports up to 65536 bytes'
60+
6061
},
61-
function (pdu) {
62-
if (pdu.command_status == 0) {
62+
function (pdu) { // Callback function for submit_sm
63+
if (pdu.command_status == 0) { // Successfully submitted
6364
// Message successfully sent
6465
console.log("message sent OK");
6566
} else {
6667
// Message failed to be sent
6768
console.log("message sending failed");
6869
}
69-
console.log("SOMETHING HAPPENNED:", pdu);
70+
console.log("SOMETHING HAPPENNED:", pdu); // Log the response
7071
}
7172
);
7273

7374
// Print Delivery Receipt logs in terminal if DLR is received
74-
session.on("deliver_sm", function (pdu) {
75-
console.log(pdu);
76-
if (pdu.esm_class == 4) {
77-
var shortMessage = pdu.short_message;
78-
console.log("Received DR: %s", shortMessage);
79-
session.send(pdu.response());
75+
session.on("deliver_sm", function (pdu) { // Listen for deliver_sm events
76+
console.log(pdu); // Log the response
77+
if (pdu.esm_class == 4) { // Check if the message is a delivery receipt
78+
var shortMessage = pdu.short_message; // Get the message body
79+
console.log("Received DR: %s", shortMessage); // Log the response
80+
session.send(pdu.response()); // Send the response to the SMSC
8081
}
8182
});
8283

83-
session.on("pdu", function (pdu) {
84-
console.log("GOT PDU ", pdu);
84+
session.on("pdu", function (pdu) { // Listen for pdu events
85+
console.log("GOT PDU ", pdu); // Log the response
8586
});
8687
}
8788
}

Diff for: smpp-stress-tester.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
// This software is released under the MIT license. See the LICENSE file for more information.
2+
// Telecom XChange LLC Copy Right: (c) 2019-2022, Ameed Jamous. All rights reserved.
3+
// License: MIT (It's free to use, modify and distribute.)
4+
// Version: 1.0.0
5+
// Release Date: 2022-06-22 (Last Updated: 2020-06-22)
6+
// Description: SMPP stress tester using node.js.
7+
// Github Repository: https://github.com/telecomsxchange/smpp-client-nodejs.git
8+
// Warranty: No warranty is provided. The software is provided "as is".
9+
// --------------------------------------------------------------------------------------------------------------------
10+
11+
112
//const nanoid = require('nanoid')
213

314
var { nanoid } = require("nanoid");
@@ -10,7 +21,7 @@ var smpp = require('smpp');
1021

1122
var session = smpp.connect('smpp://YOUR-SMPP-IP-OR-DOMAIN:PORT');
1223

13-
// Billing TLV - Works with TCXC Platform only
24+
// Billing TLV - Works with TCXC Platform only, you can use this TLV to send the billing price to the SMSC via SMPP.
1425

1526
smpp.addTLV('billing_price', {
1627
id: 0x1520,
@@ -35,7 +46,7 @@ session.bind_transceiver({
3546

3647
// SMPP Credintials used during the test.
3748

38-
system_id: 'ENTER SMPP USER',
49+
system_id: 'ENTER SMPP USER',
3950
password: 'ENTER SMPP PASSWORD'
4051

4152
}, function(pdu) {

0 commit comments

Comments
 (0)