Identifying CommSSL_Read timeout in RPGLE

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
jjacobs207
Posts: 16
Joined: Mon Aug 07, 2023 5:59 pm

Identifying CommSSL_Read timeout in RPGLE

Post by jjacobs207 »

Identifying CommSSL_Read timeout in RPGLE

I've read previous posts and understand the meaning of the error; however, it's a difficult error to replicate at will.
I've modified HTTPAPI to return the HTTP Response Status Code from RPGLE HTTPCMDR4.

POST example:
rc = http_url_post_raw2(...)

peRspStsCde = rc;
if peRspStsCde = 1;
peRspStsCde = 200;
endif;

if rc = 1 or rc>=200 and rc<300;
// success!
else;
printError();
//cleanup(5); Causes Escape message and then HTTP Status Code is not returned
cleanup(0);
return;
endif;
// As you can see, I've commented out "cleanup(5)" and changed it to "cleanup(0)" for the reason stated in the commented line.

Back in my calling RPGLE program, I consider codes 200 and 202 a success.
If the code is GE 400, I retry.
With CommSSL_Read timeout error, I believe rc = 0, so follows the value of my HTTP Response Status Code.

I could consider a value of 0 an error that I should do a retry on. However, I don't know if that's wise. Though a retry does not hurt, repeated retries cause the caller of my program to wait longer for a response. I'd also like to better identify the cause when the return code is 0.

How can I identify that a CommSSL_Read timeout error has occurred?
Scott Klement
Site Admin
Posts: 671
Joined: Sun Jul 04, 2021 5:12 am

Re: Identifying CommSSL_Read timeout in RPGLE

Post by Scott Klement »

rc = 0 generally means that a timeout has occurred. It may be a timeout from a different part of the code, though, it might not be a read timeout specifically.

If you specifically want to identify a read timeout, you can call http_error() to get the error number. The error number constant HTTP_BRTIME will indicate a timeout during a read.
Post Reply