0

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);
}
}
Peter O.
  • 32,158
  • 14
  • 82
  • 96
AdityaTS
  • 89
  • 11
  • I doubt anyone can tell you any more than exactly what the error message without you posting the minimal code necessary to generate the error. – Ben Oct 27 '12 at 18:01

1 Answers1

0

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.

Udo Held
  • 12,314
  • 11
  • 67
  • 93
  • Thanks. I tried connecting to few other services. I get the same error. Problem doesn't seem to be in the target. Is there anyway I can get around this issue? – AdityaTS Oct 27 '12 at 17:52
  • I don't know if Resty supports proxies. You can try to set a proxy, but it may not work for you: http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html Check the Resty documentation for proxy support. – Udo Held Oct 27 '12 at 17:55
  • I guess you are right. Resty didn't support proxy. So I set up the proxy manually and went with jsonsimple. – AdityaTS Oct 31 '12 at 19:25