0

I developed a simple application, calls currency converter webservice from www.webservicex.net. and deployed it on GenyMotion AndroVM.

But I am getting below error,

"Cannot connect to www.webservicex.net on port 80: java.net.ConnectException: Connection timed out"

We have proxy and I defined proxy settings as well. I am able to access internet using browser inside AndroVM.

Please help

ArK
  • 20,698
  • 67
  • 109
  • 136

1 Answers1

1

In Android, the system's proxy settings is not applied to all Http requests you made inside your app. It is applied natively inside the browser only that's the reason why you can use it. Each application has to handle it "manually".

My first and quick advise is to use OkHttp as Http client because it handles it for you.

Or you can get the values manually and configure yourself your requests like this (gathered from here):

String host = System.getProperty("http.proxyHost");
String port = System.getProperty("http.proxyPort");

DefaultHttpClient httpclient = new DefaultHttpClient();

HttpHost proxy = new HttpHost(host, Integer.parseInt(port));
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
Community
  • 1
  • 1
eyal-lezmy
  • 7,090
  • 3
  • 41
  • 35