I am doing the following code to test whether a service is up or not , but I am always getting error , can you please point me what I am doing wrong. The one I am trying to invoke is a dotnet webservice. I tried giving port also , But that also didn't work
var http = require('http');
var options = {
host: 'www.test.com/SomeService.svc'
};
http.get(options, function(res) {
console.log('got response: ' + res.statusCode);
}).on('error', function(err) {
console.log('got error: ' + err.message);
});
I am getting below error.
got error: getaddrinfo ENOTFOUND
host should be just the hostname... www.test.com.
The request path is not part of the hostname. With recent versions of Node.js, you can just pass a string URL to the first parameter in .get. No need for the options object if you have a URL.
http.get('http://www.test.com/SomeService.svc', function (res) {