Fixed now! The host wasn’t found because I was including http in the url.
I’m experimenting with Node.js createClient, however it only works when I set the host to localhost. If I try e.g. http://google.com I get the error below. What is causing this problem, could it be a firewall issue?
var http = require('http');
var url = require('url');
var u = require('util');
var site = http.createClient(80, "http://google.com", false);
var req = site.request("GET", "/");
req.end();
req.on('response', function(res){
res.on('data', function(chunk){
console.log('BODY:' + chunk);
});
});
Error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: getaddrinfo OK
at errnoException (dns.js:31:11)
at Object.onanswer [as oncomplete] (dns.js:140:16)
Node.js process terminated
You’re creating an HTTP request, and you should give it
"google.com"as the host not"http://google.com"Edit: It’s not an url, that’s why you don’t put the protocol (http://) to it, it’s the host.