Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Edith1
Creator
Creator

Use HTTP Proxy - Is there a way to automatically turn on/off to use proxy?

Hello all, I am using component tRestClient and turn off proxy (in Advanced Settings - uncheck use HTTP proxy) to run the job on my local computer, however, when I need to remote execute job on TAC server I need to turn on proxy. Is there a way to code or program this setting automatically using context variables?

Labels (2)
8 Replies
gjeremy1617088143

Hi, yes you can via the dynamic settings view in the component.

Edith1
Creator
Creator
Author

Thanks for the feedback @guenneguez jeremy​.

I cannot get the dynamic setting to work though. I attached a screenshot of a simple job with the trestclient set up. The context.UseProxy is a boolean variable. What am I missing? When the UseProxy is true, will it use the host, port and username info listed on the advance settings? In advanced setting, the "use HTTP Proxy" is highlighted yellow. I did add the host and port.

gjeremy1617088143

Hello you did it right, when the variable is true it use all informations you enter , if it's not it dont use proxy.

The "use HTTP Proxy" is highlighted yellow because now it's dynamic and is your variable wich control it.

Send Me love and Kudos

Edith1
Creator
Creator
Author

Thanks @guenneguez jeremy​  for the response 😀. The dynamic settings for trestclient on studio version 7.3 does not work. Oh well, I'm hoping Taland can fix this in the future.

gjeremy1617088143

maybe I have a solution by code injection in the component :

so first create a context variable proxy with the boolean value.

then

in TRestClient advanced settings :

Connection timeout (seconds) value : 30 * 1000L));/*

Receive timeout (seconds) value : 60 * 1000L));boolean use_proxy_tRESTClient_1 = context.proxy;//

proxy password value : ""*/if (use_proxy_tRESTClient_1) {final String decryptedPassword_tRESTClient_1 = "your password here"

 

if you look the code generated in the code view, those injections will comment a part of the trestclient code and write a new one with your boolean as triggering value for use proxy.

Send me love and Kudos

0695b00000Eb8kPAAR.jpg 

gjeremy1617088143

Hi if my answer is ok could you select it as the best please

Edith1
Creator
Creator
Author

That's exactly what I did before. It seems like the context Boolean variable for the dynamic setting is not being recognized. When I manually change the dynamic setting from false to true, it works fine. However, when its pointing to the context variable, it doesn't work.

 

Here's the code for the job:

if (!inOSGi) {

conduit_tRESTClient_1.getClient().setReceiveTimeout((long) (60 * 1000L));

conduit_tRESTClient_1.getClient().setConnectionTimeout((long) (30 * 1000L));

boolean use_proxy_tRESTClient_1 = context.UseProxy;

 

}

 

Here's the error I get when the context variable is TRUE ( I'm printing to console the context variable to ensure it's turning on or off).

 

Starting job TestAPI_ProxyOnOff at 09:24 07/05/2021.

[statistics] connecting to socket on port

[statistics] connected

********** Iteration: 1 Seconds2Wait: 0 ********** 

********** Completed Job - UseProxy_Context Value: true **********

 

[statistics] disconnected

May 07, 2021 9:24:50 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging

WARNING: Interceptor for {https://xxxx/xxxxx}tRESTClient has thrown exception, unwinding now

org.apache.cxf.interceptor.Fault: Could not receive Message.

 

 

 

**So technically the Dynamic setting works if you manually change the value; however it doesn't work if you automate the value to use the context Boolean variable. **