- Wed Feb 25, 2015 10:50 am
#10698
Found the answer.
File.read() will sequentially read until EOF (end of file), in chunks of LUAL_BUFFERSIZE.
Until build 2015-02-13, LUAL_BUFFERSIZE was 1024 bytes.
Therefore, in the code above, a file.read() was returning 1024 bytes into the "data" variable, which was then sent out. When the callback arrived, another file.read() would gather 1024 bytes, and so on, until the whole file is sent. This worked since bursts of 1024 bytes fits in the SDK's buffer size (1460 bytes) to send data out.
As of 2015-02-13, LUAL_BUFFERSIZE was changed to 4096. This means that a call such as:
Will gather up to 4096 bytes.
When those 4096 byte are sent, and as this is bigger than the SDK's buffer size, data loss will inevitably take place.
A workaround is to manually read a fixed number of bytes rather than to rely on LUAL_BUFFERSIZE.
Eg: