How to set Timeout seconds in http_url_post_stmf

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
Preethi
Posts: 11
Joined: Mon Apr 10, 2023 1:00 pm

How to set Timeout seconds in http_url_post_stmf

Post by Preethi »

Hi All,

During auto-scaling, the Rest API application is down for 80 seconds. Our RPG code that is consuming this Rest API is ending in error during auto-scaling. I would like to setup timeout seconds (HTTP_TIMEOUT) as 120 seconds while posting request using http_url_post_stmf. I think the default is 60 seconds. Could you please tell me how to do it.

http_url_post_stmf(%trim(url)
: json_input
: json_response
: HTTP_TIMEOUT
: HTTP_USERAGENT
: content_type );

httpapi version installed - 1.45

Thanks in advance.
stefan@tageson.se
Posts: 12
Joined: Wed Jul 28, 2021 7:55 am
Location: Viken, Sweden
Contact:

Re: How to set Timeout seconds in http_url_post_stmf

Post by stefan@tageson.se »

What's stopping you from using 120 as the fourth parameter in the call to http_url_post_stmf?
Preethi
Posts: 11
Joined: Mon Apr 10, 2023 1:00 pm

Re: How to set Timeout seconds in http_url_post_stmf

Post by Preethi »

Should we use any API to set timeout or directly give 120 seconds in the API call?
stefan@tageson.se
Posts: 12
Joined: Wed Jul 28, 2021 7:55 am
Location: Viken, Sweden
Contact:

Re: How to set Timeout seconds in http_url_post_stmf

Post by stefan@tageson.se »

Have a look in qrpglesrc member httpapi_h and read up on the functions you are using:

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* http_url_post_stmf(): Post data to CGI script from stream file
*
* peURL = url to post to (http://www.blah.com/cgi-bin/etc)
* pePostFile = Filename (in IFS) of file to send to http server
* (request body document)
* peRecvFile = Filename (in IFS) of stream file containing reply
* (response body document)
* peTimeout = (optional) give up if no data is received for
* this many seconds.
* peUserAgent = (optional) User-Agent string passed to the
* server. Pass *OMIT for the default
* peContentType = (optional) content type (MIME type) to supply
* to the server. Pass *OMIT for default.
* peSOAPAction = (optional) string used to specify the action
* taken by some SOAP applications.
* - pass *blanks to send an empty SoapAction.
* - pass *omit (or don't pass the parm at all) if
* you don't want a SoapAction header to be sent.
*
* Returns (same as http_url_post)
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The fourth parameter gives you the option to set the timeout value in the call directly.
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: How to set Timeout seconds in http_url_post_stmf

Post by Scott Klement »

HTTP_TIMEOUT is just a constant containing the default timeout value from config_h. IF you want a different value, pass that value instead of HTTP_TIMEOUT
Post Reply