Page 1 of 1

Identifying CommSSL_Read timeout in RPGLE

Posted: Mon Apr 29, 2024 8:28 pm
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?

Re: Identifying CommSSL_Read timeout in RPGLE

Posted: Mon Apr 29, 2024 9:32 pm
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.