I am trying to connect using the proxy with the code below but have come across an issue where it is failing with No Route to host exception.
if (httpProxyHost != null && httpProxyHost.length() > 0) {
if (httpProxyPort != null && httpProxyPort.length() > 0) {
int port = Integer.parseInt(httpProxyPort);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(httpProxyHost,port));
}
}
client = ApiClient.Builder.standard()
.withAccessToken(getAccessToken())
.withBasePath(getBasePathUrl())
.withShouldThrowErrors(true)
.withConnectionTimeout(connectionTimeout)
.withProxy(proxy)
.build();
Upon investigation, it look like on the ApacheHttpClientConnectorProvider
class, where the proxy is being set, it is only passing in the Host address and not the host port resulting in the port being -1.
Are you able to confirm this is as expected or is it a defect?
Proxy proxy = properties.getProperty(ApiClientConnectorProperty.PROXY, Proxy.class, null);
if (proxy != null) {
SocketAddress address = proxy.address();
if (address instanceof InetSocketAddress) {
InetSocketAddress inetAddress = (InetSocketAddress)address;
HttpHost proxyHost = new HttpHost(inetAddress.getAddress());
requestBuilder.setProxy(proxyHost);
}
}