Multiple transfers don't receive all data after first transfer

If I send a large file (> 7MB) as single transfer, the client gets the whole file. However, if I send it again, the client doesn't receive the full file (seems to vary). I have to restart the server each time. Seems like a buffer is not being cleared perhaps?

Example, Client A sends a large file to Client B. Client B gets the whole file. Then either Client A sends a large file to Client B OR Client B sends a large file to Client A, the receiving client doesn't get the whole file. So it seems like it is something with the server.

In my case, zip file transfers are between a Windows app (running both a server and a client dropped on a Frame) and a mobile app on Android or iOS (running a client).

Delphi 11.3
FNC Websocket


We tried this here with two Windows applications but we could not reproduce it. Can you try to run your mobile app on Windows (assuming it's an FMX app) to see if it still fails?

If it still fails, can you send sample applications that reproduces the issue?

Somehow the transfer is corrupting the data. I tried a winsocket transfer until it failed (2nd try). Even though in this case the received file size was the same, the data was corrupted.

To be sure it wasn't corrupted on the mobile side, I used Windows to browse my Android device and copied the file directly from the phone over to Windows (drag-n-drop). The file was not corrupted and could be unzipped.

To test corruption, I try to unzip the file. For the bad winsocket transferred file, Windows says the file was empty and 7-zip said data error in one of the zipped files (the file flagged seems consistent so far). Of course the manually transferred file was fine.

Maybe it would be easier to send you the zip file I am transferring until I can get you a sample demo. It's a 3.3MB file. I can send you a bad result file as well.

Edit: I also tried writing the data received from the server before it sends it to Client B. It is already corrupted as received by the server. And can occur even on the first transfer, which I previously thought it would always work.

I think I found the problem. I was sending the file in a thread. Meanwhile I had a UDP ping going on at 1 second intervals using a TIdUDPServer in the main thread. If I turn off the ping broadcast during the transfer, I have not been able to get the transfer to get corrupted (works fine every time so far).

Thank you for the update!

Ha... correction. My ping timer was not using the UDP server, but was using the same Websocket client that was sending the file. What an idiot!