node-smpp: Possible Memory Leak
Hi, I was wondering if someone from the team could offer dedicated support against a fee to resolve an issue we’re facing. The app seems to reach 100% CPU and clients are disconnected after that. This usually happens with high traffic of SMS. CPU profiling data points mostly towards Session._extractPDUs We have removed any blocking code but still the problem persists. The code snippet is as follows:
let server = smpp.createServer((session) => {
//get session info
let system_id, bindid;
let userData = {
smppData: null,
userPermInfo: null,
routeData: null
};
let processBind = {}; //this object stays within this core
let sharedBind = {}; // this object is shared among all processes
session.on('bind_transceiver', (pdu) => {
//authorize the session
log(`TRx PDU Received on ${process.env.WorkerName}:`, pdu);
session.pause();
system_id = pdu.system_id;
bindid = Math.random().toString(36).substring(3);
smppAuth(pdu.system_id, pdu.password, async (err, userSmppdata) => {
if (err || userSmppdata==undefined) {
session.send(pdu.response({
command_status: smpp.ESME_RBINDFAIL
}));
session.destroy();
log(`BIND FAILED: Invalid Credentials`);
return;
}
userData.smppData = userSmppdata;
//get user permissions and routedata for this bind
let [userPermInfo, routeData] = await Promise.all([ getUserPermissions(userSmppdata.user_id), getRouteDetails(userSmppdata.route_id) ]) ;
userData.userPermInfo = userPermInfo;
userData.routeData = routeData;
userPermInfo = routeData = null;
session.send(pdu.response());
session.resume();
log(`TRx BIND EXTABLISHED from ${client_ip}: Waiting for incoming PDU on ${process.env.WorkerName}..`);
//---
processBind = sharedBind = null;
});
});
session.on('submit_sm', (pdu) => {
let sequence_number = pdu.sequence_number;
let msgid = uuidv1(); //vendor msg id
//-- start async processessing of PDU
let userobj = userData;
asyncProcessPdu(pdu, userobj).then( res => {
if(res.status=='error'){
session.deliver_sm(res.options);
log('Some Error occurred: Response PDU sent..');
}
});
session.send(pdu.response({
message_id: msgid,
sequence_number: sequence_number
}));
log(msgid);
});
session.on('unbind', (pdu) => {
session.send(pdu.response());
log(`SESSION DISCONNECTED`);
session.destroy();
});
session.on('enquire_link', (pdu) => {
session.send(pdu.response());
});
session.on('deliver_sm_resp', (pdu) => {
let result = someTask(pdu.sequence_number, pdu);
result.then(()=>{
log('Delivery Acknowledgement saved in Database . . .');
})
});
});
server.listen(2775);
Anything looks suspicious here? I’m open to suggestions. -Thanks in advance
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
@juliangut I confirm that my issues were solved with this modification in the _extractPDUs method. I tested with varying degrees of SMS and DLR traffic which previously caused the Node process to shoot up to 100% CPU, not anymore.
Thank you so much.
-Cheers