Skip to Content
avatar image
Former Member

XS Engine HTTP Request: resolving DNS host name failed

Hi Experts

I've written the following code

Images.xshttpdest

host = "www.loc.gov";

port = 80;

description = "Library of Congress Images";

pathPrefix = "/pictures/search/?fo=json&q=";

authType = none;

useProxy = true;

proxyHost = "proxy";

proxyPort = 8080;

timeout = 0;

searchImages.xsjs

function searchImages(){

  var search = $.request.parameters.get("search");

  var index = $.request.parameters.get("index");

  if(index === undefined){

  index = 0;

  }

  var dest = $.net.http.readDestination("TM.crawler", "images");

  var client = new $.net.http.Client();

  var req = new $.web.WebRequest($.net.http.GET, search);

  client.request(req, dest);

  var response = client.getResponse();

  var body;

  if(response.body){body = response.body.asString(); }

  $.response.status = response.status;

  if(response.status === $.net.http.INTERNAL_SERVER_ERROR){

  $.response.contentType = "application/json";

  $.response.setBody('body');

  }

  else{

  $.response.contentType = "text/html";

  var searchDet = JSON.parse(body);

  var outBody =

  'First Result of ' + searchDet.search.hits + '</br>'+

  '<img src="' + searchDet.results[index].image.full + '">';

  $.response.setBody( outBody );

  }

}

searchImages();

Found the following

Error: HttpClient.request: request failed. The following error occured: unable to establish connection to proxy:8080 - internal error code: resolving DNS host name failed (line 11 position 0 in /TM/crawler/searchImages.xsjs)

Can you suggest me solutions.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jan 13, 2015 at 05:39 AM

    Hi Shashank,

    First please make sure you really need proxy to make the XSJS outbound connectivity. If so confirm your proxy works and the port is 8080. Try to replace "proxy" with the full proxy host name.

    Best regards,

    Wenjun

    Add comment
    10|10000 characters needed characters exceeded