What happens in a HTTPAPI call when the target system is unavailable?
How long is the timeout wait?
Can the timeout period be reduced?
I am using HTTPAPI in an interactive situation. If there is a remote failure, we cannot have the system locking the system until the timeout expires. I would like to see if there is a way to identify the failure.
Thanks, Darryl Freinkel.
HTTPAPI Timeout question
Re: HTTPAPI Timeout question
Most of the APIs in HTTPAPI offer an optional timeout parameter Darryl which allow you to specify the timeout delay in seconds. For example:
The return code allow you to differentiate between success, failure, and timeout.
Just search the header file for the word "timeout" there's over 60 references.
Code: Select all
D http_get PR 10I 0 extproc('HTTP_URL_GET')
D peURL 32767A varying const options(*varsize)
D peFilename 32767A varying const options(*varsize)
D peTimeout 10I 0 value options(*nopass)
D peUserAgent 16384A varying const options(*nopass:*omit)
D ...
Just search the header file for the word "timeout" there's over 60 references.
-
- Site Admin
- Posts: 671
- Joined: Sun Jul 04, 2021 5:12 am
Re: HTTPAPI Timeout question
I would prefer that people not use the old APIs like the one Jon posted for new applications.
Instead, use http_req, http_stmf or http_string.
You mention the other system is "unavailable". The timeout only applies to lack of data being received -- i.e. you try to connect and get no response, or you are expecting to be able to send or receive data and get no response for the given number of seconds.
Frequently when a system is unavailable, it's because the HTTP server isn't running on that system. In that case, you wouldn't get a timeout, you'd get an error connecting (typically "Connection Refused" but sometimes "Host not available") That is because the TCP/IP stack on the remote computer's operating system is still running, even if the program is not. And so it will send back an error code immediately.
Instead, use http_req, http_stmf or http_string.
Code: Select all
http_setOption('timeout': '30'); // time out after 30 seconds
rc = http_req(...parameters...);
Frequently when a system is unavailable, it's because the HTTP server isn't running on that system. In that case, you wouldn't get a timeout, you'd get an error connecting (typically "Connection Refused" but sometimes "Host not available") That is because the TCP/IP stack on the remote computer's operating system is still running, even if the program is not. And so it will send back an error code immediately.
-
- Posts: 12
- Joined: Mon Aug 29, 2022 10:39 pm
Re: HTTPAPI Timeout question
Thank you.
I'll add your recommendation in the program.
Darryl.
I'll add your recommendation in the program.
Darryl.