events.js:183 throw er; // Unhandled ‘error’ eventError: read ECONNRESET at _errnoException (util.js:1022:11) at TCP.onread (net.js:615:25)
How to solve this error?
I got the above error when i tried to send the SMS link to the URL (uri: contains api key,username,password,phone number and text)
I have to send the SMS to 2000 people at a time.
Here is the piece of code where i am sending the sms link to the url…
function SendSMSToURL(uri)
{
var request = http.get(uri, function (response)
{
var buffer = "",
data,
route;
response.on("data", function (chunk) {
buffer += chunk;
});
response.on("end", function (err)
{
var data = buffer;
console.log("data", data);
console.log("SMS sent...");
return data;
});
},
function (err) {
console.log("SMS not sent...");
return "bad";
});
I think this much is enough.
By using this function i am able send sms only to 30-50 people after that it got crashed since i am sending 2000 people details so please help me out.
function SendSMSToCustomerWithText(phonenumber, custName, smstext, senderId)
{
var msg;
var httplinkstr = “http://bhashsms.com/api/sendmsg.php?";
var usernamenpasswd = “user=xxxxxxxxx&pass=xxxxxxxxxxx&sender=” + senderId + “&phone=”;
if (custName == “” || custName==null)
{
msg = “&text = XYZ” + smstext;
}
else
{
msg = “&text=Dear " + custName + “,” + smstext;
}
var smsmode = “&priority=ndnd&stype=normal”;
var smsMsg = httplinkstr + usernamenpasswd + phonenumber + msg + smsmode; //console.log(smsMsg);
SendSMSToURL(smsMsg);
}
function SendSMSToURL(uri)
{
var request = http.get(uri, function (response)
{
var buffer = “”,
data,
route;
response.on(“data”, function (chunk)
{
buffer += chunk;
});
response.on(“end”, function (err) {
console.log(‘buffer’, buffer);
console.log(”\n”);
var data = buffer;
console.log(“data”, data);
console.log(uri);
console.log(“SMS sent sucessful”);
return data;
});
},
function (err) {
console.log(“SMS Sent is not sucessful”);
return “bad”;
}
);
}
“function SendSMSToURL(uri)”…to this function i am referring
Mr.Pavel has suggested me to assign a function with the “request” variable. But i don’t have any idea what to do with that.
Please help me out if you have any suggestion…