question

Upvotes
16 14 15 17

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
icon clock
10 |1500

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

I have contacted TRKD_API_DEVSUPPORT to verify this question.

Upvotes
381 1 3 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");

icon clock
10 |1500

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

Upvotes
16 14 15 17

@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?

icon clock
10 |1500

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

Upvotes
16 14 15 17

@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?

icon clock
10 |1500

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

Upvotes
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.

icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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