Proxy Port Issue

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);
	}
}

Hm, looks like it's stripping out the proxy port. I've created API-2832 to use the port correctly.

Give it a try with v18.0.0+ and let me know if you're able to successfully connect with a proxy.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.