return code -1

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
eric@negsys
Posts: 7
Joined: Thu Sep 14, 2023 8:56 am

return code -1

Post by eric@negsys »

Hi everybody,

My job is not to develop but I have to maintain a program that does not work.
Don't be too hard on me because my technical level is far from that of an expert ;) . I explain my problem.

Purpose of the program: connection to a remote server to retrieve stock data.
Note that the two tests described below are executed from 2 different iSeries but the connection to retrieve the data is made on the same remote server. ach iSeries is in version V7R3

When this program is run on our server, everything works correctly (duration between 30 and 40 seconds).
When this program is executed on our client's server, it is interrupted after a few seconds. the program started to recover data but very little.
HTTPAPI_Version is 1.39

You will find in attachments: the program source code, the two logs
File named “Log_http_client.txt” corresponds to the log produced on our client's iSeries. At the end, there is a return code get_chunk_size returned -1
File named “Log_http_our server.txt” corresponds to the log produced on our iSeries.

I tried to contact IBM support and I sent them a trace (TRCCNN) and the logs but they found nothing and advised me to come here on this forum.

Thanks for your help.
Eric.
Attachments
Logs & code source.rar
(97.25 KiB) Downloaded 635 times
jonboy49
Posts: 206
Joined: Wed Jul 28, 2021 8:18 pm

Re: return code -1

Post by jonboy49 »

That's a pretty old version - I believe the current version is 1.49. So first advice is to update HTTPAPI.

P.S. Might I also suggest using a regular zip file. My Mac thinks rar files are videos and I haven't the time to search for a way to unzip your source.
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: return code -1

Post by Scott Klement »

For the document that works, there doesn't seem to be any problems. It is using chunked transfer coding, so you see this:

Code: Select all

get_chunk_size(): entered
ee7

chunk size = 3815
get_chunk_size returned 3815
calling comm_blockread
the 'ee7' is being sent by the server to indicate the length of the next chunk of data. Hex ee7 is the same as decimal 3815 -- so HTTPAPI's "get_chunk_size" routine has received 3815 as the length, and then it calls comm_blockread to read that data.

After all chunks of data are received, you can see this:

Code: Select all

get_chunk_size(): entered
0

chunk size = 0
get_chunk_size returned 0
The size = 0 means there isn't more data.

By contrast, in the ne that's not working you see this:

Code: Select all

1G

get_chunk_size(): entered
get_chunk_size returned -1
This is telling HTTPAPI that the chunk size is 1G -- however, 1G isn't a valid hex number, so get_chunk_size can't interpret it... that's why it's returning -1 to indicate an error.

so the question is, why us "1G" being returned by the server??
eric@negsys
Posts: 7
Joined: Thu Sep 14, 2023 8:56 am

Re: return code -1

Post by eric@negsys »

Thanks for the answers. I’ll analyze your answers and do some research
For jonboy49, the files are compressed in zip file
Attachments
Logs & code source.zip
(108.21 KiB) Downloaded 632 times
eric@negsys
Posts: 7
Joined: Thu Sep 14, 2023 8:56 am

Re: return code -1

Post by eric@negsys »

@Klement, where do you find the value 1G? I can't find it using Ctrl+F
At the end of the log I see

get_chunk_size(): entered
2006

chunk size = 8198
get_chunk_size returned 8198
calling comm_blockread
,"ATV4":"","ATV5":"","FUDS":"COSSES PLATES FEMELLES ROUGE Ø6.3MM - 10 PIECES"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12305002","ITDS":"COSSE BATTERIE 50 boite de 2","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"C","ITTY":"300","RESP":"MARLAB","UNMS":"UN","ITGR":"ENM","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230802","ODDT":"20230906","INDT":"","INON":"0","STAS":"2","RCLS":"","PRDT":"20230802","STQT":"5","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"5","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"COSSES BATTERIE POUR CABLE DE 50 MM2"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12305005","ITDS":"MULTIMETRE DIGITAL","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"C","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230802","ODDT":"20230811","INDT":"20230506","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"8","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"8","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"MULTIMETRE A AFFICHAGE NUMERIQUE"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12305201","ITDS":"ETAU 200MM","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"B","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230824","ODDT":"20230906","INDT":"20230713","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"1","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"1","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"ÉTAU A BASE TOURNANTE 200MM"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12305370","ITDS":"CRIC 20 TONNES","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"B","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230901","ODDT":"20230908","INDT":"20230512","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"8","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"8","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"CRIC BOUTEILLE - 20T"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12305606","ITDS":"CHANDELLES MECA 6T LA PAIRE","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"B","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230822","ODDT":"20230907","INDT":"20230506","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"9","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"9","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"CHANDELLES MECANICIEN 6T - 2 PIECES"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12305710","ITDS":"GRUE D ATELIER MOBILE 1T","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"B","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230829","ODDT":"20230829","INDT":"20230506","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"1","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"1","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"GRUE D'ATELIER - 1T"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12306060","ITDS":"ADAPTATEUR POUR FUT","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"B","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230731","ODDT":"20230911","INDT":"20230506","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"23","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"23","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"ADAPTATEUR PVC POUR POMPE DE FUT"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12306061","ITDS":"BURETTE METAL 250ML BEC RIGIDE","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"C","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230912","ODDT":"20230912","INDT":"20230506","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"25","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"25","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"BURETTE EN METAL DE 250ML"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12306062","ITDS":"COFFRET 140 GRAISSEURS","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"B","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230818","ODDT":"20230908","INDT":"20230506","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"16","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"16","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":"","ATV2":"","ATV3":"","ATV4":"","ATV5":"","FUDS":"COFFRET ASSORTIMENT 140 GRAISSEURS"},{"CONO":"100","WHLO":"F10","WHNM":"VIC LOUDEAC SPIDY","ITNO":"12306063","ITDS":"COFFRET 70 GRAISSEURS","WHSL":"STOCK","BANO":"","CAMU":"","REPN":"0","ABCD":"B","ITTY":"300","RESP":"ANNPER","UNMS":"UN","ITGR":"OUA","PLCD":"10","SLTP":"IN","WHLT":"99","IDDT":"20230912","ODDT":"20230908","INDT":"20230506","INON":"0","STAS":"2","RCLS":"","PRDT":"20230506","STQT":"28","PHSQ":"0","ALOC":"1","ALQT":"0","PHAQ":"0","AUDE":"1","AUDD":"0","STAQ":"28","PHA2":"0","POCY":"0.00","CAWE":"","LPCY":"0.00","PPUN":"UN","BREF":"","PACT":"","BRE2":"","BREM":"","REOP":"0","ATNR":"0","ATNB":"0","STAT":"20","CAW2":"0","INDI":"0","BACD":"0","EXPD":"0","ACTI":"0","ATMN":"0","CWUN":"UN","COMG":"0","MVB1":"","MVB2":"","ABFC":"A","STNB":"0","OPAN":"","ATV1":""
comm_blockread returned 8192
calling comm_blockread
,"ATV2
comm_blockread returned 6


get_chunk_size(): entered
get_chunk_size returned -1
http_close(): entered
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: return code -1

Post by Scott Klement »

eric@negsys wrote: Fri Sep 15, 2023 1:46 pm @Klement, where do you find the value 1G? I can't find it using Ctrl+F
[SNIP OUT IRRELEVANT PARTS]
get_chunk_size(): entered
get_chunk_size returned -1
http_close(): entered
lol... I just grabbed your logs again, and I agree -- there's no 1G. I must've fat-fingered that into the log earlier... sorry about that.

The -1 means it received a network error of some sort reading the length of the chunk size.

In your code, you have this, which looks like it's probably where the problem is occurring:

Code: Select all

173	221011	c                   eval      rc = http_url_get( %trimr(URL0): REPAPI)
174	221011	*
175	221011	c                   if        rc <> 1
176	221108	c                   move      'E'           cret$$
177	221011	c                   callp     http_comp(http_error)
178	221108	c                   goto      finstk
179	221011	c                   endif
Notice that on line 177, if the rc is -1, this will call http_error() to get the error that occurred, and then call http_comp() to write the error as a completion message. Can you tell us what that message says?
eric@negsys
Posts: 7
Joined: Thu Sep 14, 2023 8:56 am

Re: return code -1

Post by eric@negsys »

Hello,
Please, can you help me where I can find the message ? There is nothing in QSYSOPR.

One important detail, sometimes the program runs successfully.
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: return code -1

Post by Scott Klement »

Completion messages are sent to the caller's program queue. Because they are in a program queue, they'd typically also be in the job log.
eric@negsys
Posts: 7
Joined: Thu Sep 14, 2023 8:56 am

Re: return code -1

Post by eric@negsys »

We have no joblog and nothing special in the log session as you can see below.
Please how can I have a joblog with a lot of detail ?

3500 - CALL PGM(IM3STKG0) /* La commande CALL contient des
paramètres */
Ouverture du membre IFDSGP00 changée en SEQONLY(*NO).
Ouverture du membre IFESGP00 changée en SEQONLY(*NO).
HTTP/1.1 200 OK
3900 - SNDDST TYPE(*LMSG)
TOINTNET(('synchronisation@vital-concept.com'))
DSTD('Alerte-IM3-Contrôle de stock') MSG('VIT - ALERTE - INFOR M3 CTL
STK IMPOSSIBLE - IM3STKP0') LONGMSG('VIT - ALERTE - INFOR M3 CTL STK
IMPOSSIBLE - IM3STKP0')
La distribution a été effectuée.
13200 - DLTOVR FILE(*ALL)
Aucune substitution au niveau indiqué.
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: return code -1

Post by Scott Klement »

eric@negsys wrote: Tue Sep 26, 2023 1:33 pm We have no joblog and nothing special in the log session as you can see below.
Please how can I have a joblog with a lot of detail ?
I already see all of the details in your message, so I don't need a more detailed job log.

But, for future reference, to ensure you have full details in the job log, I'd recommend setting your job settings like this (many shops have this as the default, so yours may already be this way.) Do this before running HTTPAPI:

Code: Select all

CHGJOB LOG(4 00 *NOLIST)
Then, after running the program when you want to print a detailed job log (as a spooled file) you would do this:

Code: Select all

DSPJOBLOG OUTPUT(*PRINT)
But, the completion message that was mentioned as follows (from the job log text you posted):

Code: Select all

  HTTP/1.1 200 OK 
As you can see, it isn't helpful. It just says that the request was successful... not very useful.

So what we are seeing is a problem I've never seen before, and HTTPAPI isn't generating any helpful diagnostics. In order to help you further, I would need a program that I can load/run on my system that I can use to reproduce the problem. It's important that it run on my system, and that it reproduce the exact same problem, because I'm going to have to do in-depth debugging to understand what is happening.
Post Reply