sitemule / ILEastic

Embedded application server for ILE on IBM i
Apache License 2.0
58 stars 29 forks source link

il_responseWriteStream returns incomplete JSON #106

Open SteffenHaugeKtp opened 3 years ago

SteffenHaugeKtp commented 3 years ago

I made a simple program that selects every from a file and returns it as JSON via noxDB.

Following the example file: noxdbcust.rpgle

`dcl-proc jsonTest;

dcl-pi *n;
    request  likeds(IL_REQUEST);
    response likeds(IL_RESPONSE);
end-pi;

dcl-s pResult pointer;

// Assume everything is OK
response.status = 200;
response.contentType = 'application/json';

// Use noxDB to produce a JSON resultset to return
pResult = json_sqlResultSet ('select * from MY_FILE');

// Use the stream to input data from noxdb and output it to ILEastic
il_responseWriteStream(response:json_stream(pResult));

end-proc;`

But it seems to return invalid JSON, it looks like its getting cut off at the end, sometimes? It seems to occur if i select enough data from a single file.

If i use json_writejsonstmf to dump the data to a IFS file it's correct.

NielsLiisberg commented 3 years ago

Ok - so it seams like the stream-feature either on noxDb or in ILEastic is doing something "undocumented" ... I'll take a look. Thank you for the Feedback

m1h43l commented 2 years ago

@SteffenHaugeKtp Could you tell us how "big" the data was which did get cut off when using il_responseWriteStream (how large was the IFS file)?

SteffenHaugeKtp commented 2 years ago

I was selecting text from a DB2 file ie. _SELECT text FROM db2_file LIMIT 1000_

The problem seems to be øæå characters in the string field i select from. If i change the first record in the DB2 to contain any of øæå characters and then do _SELECT text FROM db2_file LIMIT 1_ Then the http request returns 0 bytes.

But if i do the query with a sufficient big enough limit (100+) it returns some JSON but it's incomplete.

m1h43l commented 2 years ago

@SteffenHaugeKtp What is the CCSID of the table and column and what is the CCSID of the job running the web service program?

SteffenHaugeKtp commented 2 years ago

Everything is CCSID 277