AsyncHttpClient doesn't use the HTTPS port set in the constructor

922 views Asked by At

I'm trying to change the port I'm using for HTTPS connection between my Android client and my server, but the port doesn't get set for some reason. I initialize the HTTP client like this:

// Use port 8185 for HTTPS
client = new AsyncHttpClient(80, 8185);

... but I get an Exception:

org.apache.http.conn.HttpHostConnectException: Connection to https://192.168.1.35 refused
...
Cause by: java.net.ConnectException: failed to connect to /192.168.1.35 (port 443) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)

Based on these errors, it seems that the default port 443 is still being used. Why is that? Why can't I use the non-default port 8185?

Edit: This is the library I'm using.

1

There are 1 answers

2
Mauker On

From what I've read in the Javadocs and on the lib website, perhaps you could try something like:

AsyncHttpClientConfig cf = new AsyncHttpClientConfig.Builder().setProxyServer(new ProxyServer(ProxyServer.Protocol.HTTPS,"IP_ADDRESS", 8185)).build();
AsyncHttpClient c = new AsyncHttpClient(cf);