SalmaFG SalmaFG - 1 year ago 114
Node.js Question

Using node-orangesms to send SMS

Using NodeJS I wanted to implement the Orange SMS API: I have downloaded the

npm package for my NodeJS project. However, I am struggling with getting it to work.

I have already obtained a
from for my project. I have noticed that on the package page on NPM: it was not described where the authentication header should be inserted for sendSMS function to work. I am getting this error:

{ Error: tunneling socket could not be established, statusCode=302
at ClientRequest.onConnect (/home/salma/Desktop/project1/node_modules/tunnel-agent/index.js:165:19)
at ClientRequest.g (events.js:291:16)
at emitThree (events.js:116:13)
at ClientRequest.emit (events.js:194:7)
at TLSSocket.socketOnData (_http_client.js:394:11)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
at TLSWrap.onread (net.js:551:20) code: 'ECONNRESET' }

and I think this might be the reason why. This is my code so far:

var clientId = 'XX';
var secret = 'XX';
var userOptions = {
proxy: {
protocol: 'https',
host : '',
port : 8080
strictSSL: true

var OrangeSMS = require('node-orangesms')(clientId, secret, userOptions);

var senderAddress = 'tel:+20XXXXXXXXXX';
var senderName = 'test';

module.exports = {
sendSMS: function(recipient, content, next) {
OrangeSMS.sendSMS("tel:+"+recipient, content, senderAddress, senderName);

Answer Source

The problem was the https. It was causing an authentication failure. It worked after changing it to http.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download