Search code examples
javajsonweb-servicesresty

Connection Error in Resty


I am trying to use Resty from behind my institution proxy. I came up wtih this exception

Exception in thread "main" java.net.ConnectException: Connection refused: connect

Can someone help me telling why I am getting this exception?

Here's the complete code:

package models;
import static us.monoid.web.Resty.*;
import us.monoid.web.Resty;
import us.monoid.web.Resty.*;

public class Tracks {
public static void main(String args[])throws Exception{
    Resty r= new Resty();
    String s = r.json("http://ws.geonames.org/postalCodeLookupJSON?"+
    "postalcode=66780&country=DE").get("postalcodes[0].placeName").toString();
    //String s=r.json("http://ws.audioscrobbler.com/2.0/?method=geo.gettopartists&country=spain&api_key=4174709b0d420c7080c7ac75e6944f1c&format=json").get("topartists[0].artist[0].name").toString();
    System.out.println(s);
}
}

Solution

  • Looks like your access is blocked. You are connecting to the wrong target or its not running at all.

    Verify if you network connectivity is ok. Usually where proxies are present direct access is blocked. Depending on what you are doing you may use that proxy or request a firewall rule for you.