1. Jorge Escobar
  2. PowerBuilder
  3. Saturday, 20 June 2020 00:39 AM UTC

I am consuming a REST API from PowerBuilder 2019 R2. For this I use the HttpClient class.


When running the API from Posman, Insomnia and SoapUI the response is immediate (thousandths of a second)

 

However, when I run it from PowerBuilder, at best it takes 10 seconds and many times over 60 seconds and the app freezes.

 

inv_httpClient.ClearRequestHeaders()
// Establecer propiedades en el Header
inv_HttpClient.SetRequestHeader("Content-Type", "application/json; charset=UTF-8")
inv_httpClient.setRequestHeader( "Authorization", "Bearer" + " " + is_accessToken)
inv_HttpClient.SetRequestHeader("Content-Length", String(ll_contentLength))

inv_httpClient.Timeout = 10

lt_begin		= now()
// Ejecutar el request
li_rc		= inv_httpClient.sendRequest( "POST",ls_URL,lblb_data)

lt_end			= now() 

IF li_rc <> 1 THEN
	of_setMessage( of_getErrorHttp( li_rc ))	
	RETURN -1
END IF

 

 

  

 

The problem occurs when running from the sources and from the executable and I have even tried with PB 2017 R3.

As a test, I have created a WebService in Java from which I run the API and returns an XML that I collect via SOAP from PowerBuilder and with this the response improves considerably and the screen does not freeze. However, bringing this scenario to production implies having a Glassfish or Tomcat web server, deploying the service, etc. and it is not viable; so I have to look for a solution to slow when executing the HttpClient.sendRequest. If you have had a similar problem I will appreciate your recommendations.

 

Gracias

 

 

 

 

mike S Accepted Answer Pending Moderation
  1. Saturday, 20 June 2020 15:09 PM UTC
  2. PowerBuilder
  3. # 1

Maybe try setting the security of the HTTPclient vs what the service expects:

The SecureProtocol property specifies the secure protocol. Values are:

0 – All secure protocols. This is the default value. It will detect and use the secure protocol in the following order: TLS 1.2, TLS 1.1, SSL 2.0/SSL 3.0/TLS 1.0.

 

There is a 1.3 version as well, which should be in 2019R3.  

 

 

Comment
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Monday, 22 June 2020 08:42 AM UTC
  2. PowerBuilder
  3. # 2

Hi Jorge,

Mike is right.  Firstly, Please set the security of the HTTPClient object and see if it works better.

Secondly, did you do your test with Postman and the test with PowerBuilder on the same machine?

Please also confirm that if you enabled proxy settings on your IE Browser and see if that is causing the slowness?

 

Additionally, if you have any other tool like an HTTP monitor or HTTP sniffer, you can compare the same API request data from the HTTPClient object and Posman and see what is the exact difference. I am not sure, but you may find some different settings on your side.

 

Best regards,

Mark Lee

Comment
  1. Jorge Escobar
  2. Monday, 22 June 2020 20:39 PM UTC
Hi Mark





The tests were performed with Postman, Insomnia and SoapUI on the same PowerBuilder development machine.



I have disabled the "Automatically detect settings" checkbox in the proxy settings and thus the response is fast, just like Posman (does not exceed 1 second). This test was done on two computers and the response was satisfactory; however, on a third machine, speed did not depend on this configuration.



At the moment, until finding the source of the problem, it has been decided to create an intermediate Web Service and in this way the response is quick and does not depend on the proxy configuration.



Thank you very much, I will inform if I find any other alternative.



Jorge
  1. Helpful
  1. Mark Lee @Appeon
  2. Tuesday, 23 June 2020 01:41 AM UTC
Hi Jorge,

Thanks for your confirmation.

It seems that this issue relates to the proxy configuration of your environment.

We look forward to hearing back from you!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.