question

NWM avatar image
16 5 9 14

Proxy setting in TRKD API using Java

Hello,

How can we set proxy configuration using Java? Proxy setting is not mentioned in the TRKD API developers guide. Is there any code snippet that can be shared to show the mechanism?

Thanks

treprkd-apirkd
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mohammad.waseem avatar image
381 1 2 3

This article describes configuration of a proxy server for Java.

In order to configure a proxy server for a Java application you should set up the following system properties (seearticleon Oracle site for additional details):

For HTTP traffic:

http.proxyHost(default: <none>)

The host name, or address, of the proxy server

http.proxyPort(default: 80)

The port number of the proxy server.

http.nonProxyHosts(default: localhost|127.*|[::1])

Indicates the hosts that should be accessed without going through the proxy. Typically this defines internal hosts. The value of this property is a list of hosts, separated by the '|' character. In addition the wildcard character '*' can be used for pattern matching. For example -Dhttp.nonProxyHosts=”*.foo.com|localhost” will indicate that every hosts in the foo.com domain and the localhost should be accessed directly even if a proxy server is specified.

For HTTPS traffic:

https.proxyHost(default: <none>)

The host name, or address, of the proxy server

https.proxyPort(default: 443)

The port number of the proxy server.

Note:The HTTPS protocol handler will use the same nonProxyHosts property as the HTTP protocol.

You can use two main approaches how to set environment variables in Java applications (the following examples assume your proxy server host is "localhost" and port is 8888):

Command line option when invoking the VM:

jre -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8080 myApp

jre -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8080 myApp

Using theSystem.setProperty(String, String)method, assuming that you have permission to do so:

System.setProperty("http.proxySet", "true");

System.setProperty("http.proxyHost", "localhost");

System.setProperty("http.proxyPort", "8888");

System.setProperty("https.proxySet", "true");

System.setProperty("https.proxyHost", "localhost");

System.setProperty("https.proxyPort", "8888");

10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

NWM avatar image
16 5 9 14

@Shaikh, Thanks for the reply. With reference to Chapter 53 "Building a java client" in the TRKD API guide, how/where does the above fit in?

10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

NWM avatar image
16 5 9 14

@Shaikh, Can you please get back on the my previous question "

With reference to Chapter 53 "Building a java client" in the TRKD API guide, how/where does your solution fit in?

10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Robin Rottier avatar image
206 1 2 2

@NWM reviewing portal questions and I see your follow up was not answered. Do you still need help on that point? The response from Waseem indicated both a command line and code approach to setting the java proxy.

10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.