Open atul555 opened 6 years ago
Hi,
you need to set the proxy via property: https://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
Example:
JAVA_FLAGS=-Dhttp.proxyHost=10.0.0.100 -Dhttp.proxyPort=8800
java ${JAVA_FLAGS} ...
I tried the approach with setting the JAVA flags, but no luck. What I tried is
final Proxy proxyTest = new Proxy( Proxy.Type.HTTP, new InetSocketAddress( "127.0.0.1", 3128 ) );
final OkHttpClient.Builder builder = new OkHttpClient.Builder()
.proxy( proxyTest );
final InfluxDB influxDB = InfluxDBFactory.connect( url, influxUser, influxPassword, builder );
Which also fails, since InfluxDBImpl circumvents the OkHttpClient at a crucial point:
https://github.com/influxdata/influxdb-java/blob/master/src/main/java/org/influxdb/impl/InfluxDBImpl.java#L232
InetAddress.getByName(hostName);
Currently the code throws exception org.influxdb.InfluxDBIOException: java.net.UnknownHostException if the client sits behind the proxy and can not resolve the hostname. Hostname InetAddress is only used for UDP writes so IMHO, the constructor call in InfluxDBImpl this.hostAddress = parseHostAddress(url); can be moved to initialDatagramSocket() method. Which at least enables the HTTP traffic from behind firewall.