arcturial / clickatell-node

NodeJS library to interact with the Clickatell SMS Gateway
GNU General Public License v2.0
2 stars 6 forks source link

Transport->http.request not executing #1

Open ericlovescode opened 9 years ago

ericlovescode commented 9 years ago

Strange Error. I've got this module working fine in another node.js app. I have created another app and when it gets to line 36 in transport.js: var req = http.request(options, function (res) {

the line just does not get executed, and putting a console.log statement within the associated function block (line 37) doesn't get executed. The userid, password, and apiID are all correct.

Any ideas?

arcturial commented 9 years ago

Does it perhaps get to line 55 in transport.js. On line 55 an "error" event listener is registered that should trigger the callback with any error information. Perhaps try adding debugging in line 55 section to see if it hits that block of code.

ericlovescode commented 9 years ago

Thanks for this, Chris. No it does not go into the req.on('error'... handler. It basically bypasses the http.request returning function body and carries on after line 50. Very strange as it was a piece-of-cake getting your module to work in my 1st app. 2nd app is very similar.

arcturial commented 9 years ago

You perhaps running a different version of NodeJS on your second app?

Also, try and change the code on line 59 to:

        // Finalize the request
        req.end(options.method == "POST" ? args : '', 'utf8', function () {
            console.log('request stream done');
        });

That callback should trigger. It will indicate that the request has been sent. The http.request callback will only trigger once end has been called, since that flushes the last of the data and finishes the request.