3

My app uses AsyncHttpClient library for network operation.My problem is i need to specify the proxy with port in order to connect to remote server.Any ideas to specify it??

Stephane Landelle
  • 6,990
  • 2
  • 23
  • 29
Tom
  • 33
  • 1
  • 3

2 Answers2

7

Try like this

 AsyncHttpClientConfig cf = new DefaultAsyncHttpClientConfig.Builder()
 .setProxyServer(new ProxyServer.Builder("127.0.0.1", 38080)).build();

 AsyncHttpClient c = new DefaultAsyncHttpClient(cf);
akhil Rao
  • 1,169
  • 7
  • 17
1

Another posibility is to use the standard Java proxy-properties:

JDK_JAVA_OPTIONS=-Dhttps.proxyHost=<host> -Dhttps.proxyPort=<port> -Dhttp.proxyHost=<host> -Dhttp.proxyPort=<port>

AsyncHttpClientConfig config = new DefaultAsyncHttpClientConfig.Builder()
   .setUseProxyProperties(true)
   .build();
Hjelmen
  • 91
  • 2