Reputation: 1941
I'm using node curl to make a call to a WS. I wrote a simple function that just issues a request and I'm logging the response. This is how my server.js looks:
var http = require('http');
var curl = require('node-curl');
var config = require('./config');
var cfgObj = new config.config();
function start(port) {
function onRequest(request, response) {
console.log("Request received");
var options = {
VERBOSE: 1,
RAW: 1
};
curl.debug = 1;
curl.setDefaultOptions(options);
curl('www.google.com', function(err) {
console.log(this.body);
});
}
http.createServer(onRequest).listen(port);
}
cfgObj.getConfig(null, function(data) {
start(data.port);
});
cfgObj just contains the port number. It connected to the host properly and I even got HTTP 200 OK response:
[cURL 1] receive 2242 bytes [cURL 1] receive succeeded.
But in the end, it says:
Bus error: 10
What does this mean?
The control never calls the function where I'm printing this.body. I even tried using http request but that gives me "socket hang up" error.
I have been unable to debug this issue. Any clues?
Upvotes: 0
Views: 719
Reputation: 203359
node-curl
is broken, when I try to use it on my Mac I get the same error:
[2] 34539 bus error node test.js
(a bus error is an error which occurs when a program tries to write to an invalid memory location)
Here's a replacement for node-curl
: https://github.com/mikeal/request
Upvotes: 3