0

I use "Liberty for Java" app and Statica service(Proxy) on Bluemix. We set http.proxyHost/http.proxyPort/https.proxyHost/https.proxyPort as system properties in Java code every transactions.

for example:

URL url = new URL(xxx);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
........
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", port);
System.setProperty("https.proxyHost", host);
System.setProperty("https.proxyPort", port);
........
DataOutputStream out = new DataOutputStream(connection.getOutputStream());

I have an issue that one transaction go from the app to a target server directly in spite of tens of thousands of transactions passed the proxy.

Question 1: Do "Liberty for Java" app on Bluemix clear or update system properties, http.proxyHost/http.proxyPort/https.proxyHost/https.proxyPort? I wonder "Liberty for Java" app updated with null to access outer servers in multi-thread environment.

Question 2: Do "Liberty for Java" app on Bluemix communicate with outer servers? I found the following log in Statica.

https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.agents.na.apm.ibmserviceengage.com
https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.gateway.prd.na.ca.ibmserviceengage.com

( I masked a part of URL.)

P.S. We will change java code with ProxySelector class or Proxy class.

ralphearle
  • 1,696
  • 13
  • 18
sintheta
  • 1
  • 2

1 Answers1

1

Re #1: No.

Re #2: Potentially yes. In your case, it seems your app is bound with a Monitoring & Analytics service? If so, a data collector will be installed and will send collected data to remote servers.

What's the reason that you need to set the proxy system properties in your code? Is it because you want some connections to go through the proxy and others not?

If so, then the way you do this is not right because the system proxy setting is a global setting, not a thread-scoped setting. This means if one thread sets the proxy setting, all threads will then use that proxy; if one thread unsets it, all threads will then do direct connections. That may explain why you are intermittently seeing some direct connections. The right way is to use a http client lib that supports proxy as parameters, like https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/config/RequestConfig.Builder.html#setProxy%28org.apache.http.HttpHost%29

If you want all connections to go through the http proxy, then you should simply set the JAVA_OPTS environment variable to pass in those system properties, e.g., "-Dhttp.proxyHost=x.x.x.x -Dhttp.proxyPort=xx".

Jack-Junjie Cai
  • 599
  • 2
  • 8
  • I use Monitoring & Analytics. Our app in Bluemix must connect a target app via proxy(Statica service in Bluemix) because of the target app limit with IP address of inbound. Bluemix app changes IP address every staging. I use java.net.HttpURLConnection and java.net.URL class. I set the hostname of the target app and access the target app via proxy. I should have use other way[Java Networking and Proxies](https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html). I will change that implementation. I'm sorry for the delay in responding. – sintheta Dec 09 '15 at 05:04