RTC Forums
April 19, 2024, 02:03:49 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Sending large files using DataProvider  (Read 5688 times)
markh51
Guest
« on: December 31, 2009, 04:08:06 PM »

I have implemented a RTC client / server application to allow the client to download large (~5mb) files. I have used the demos and the "lessons" to create these. When I download a file which is around 5mb, the file appears to be corrupt on the client side when the download is complete. The byte size of both files are the same however it does not open (its a zip file).

..BUT, if I download a zip file which is around 2-3mb, it works fine. It allows me to open the file on the client side with no problems.

I have been looking at the code and I can not see a problem. I dont understand why I can download smaller files ~2mb but not ~5mb.
The server app is running on a remote computer which is accessed through a vpn. The vpn connection is establised first.

Can someone please help ?

Thanks.
Logged
markh51
Guest
« Reply #1 on: January 01, 2010, 04:42:33 PM »

After a bit of support from zsleo, if figured out if I put a Application.ProcessMessages at the end of the DataIn/ResponseData event handler, the problem is fixed, but now I want to know why this is a "fix" for the problem.

Does anyone have any idea ?!? as surely this seems to be a problem as smaller files work fine without Application.ProcessMessages at the end.
Logged
markh51
Guest
« Reply #2 on: January 01, 2010, 08:15:19 PM »

After further investigation, I noticed that Application.ProcessMessages does not always work, however if I put a sleep(5) after the write_file it always works... any ideas what the problem is ?
Logged
zsleo
RTC Expired
*
Posts: 80


« Reply #3 on: January 03, 2010, 01:05:48 AM »

To which instance of Application.ProcessMessages are you referring?

In the sample app I provided, this is (my lasy way) implemented in place of implementing callbacks.

P.S. If Application.ProcessMessages "fixes" the your problem I suspect that you are not correctly capturing/processing the multi-threaded calls
Logged
markh51
Guest
« Reply #4 on: January 09, 2010, 06:44:05 PM »

Code:
procedure TMastData.RequestFileDataReceived(Sender: TRtcConnection);
var
   s
      :string;
begin
   with TRtcDataClient(Sender) do
   if not inMainThread then
      Sync(RequestFileDataReceived)
   else
   begin
      gv_FetchCnt := 0;
      if Response.Started then
      begin
         if Request.Query.asString['fname']<>'' then
         begin
            if not DirectoryExists(ExtractFilePath(ExpandFileName(Request.info.asString['fname']))) then
               CreateDir(ExtractFilePath(ExpandFileName(Request.info.asString['fname'])));
            Delete_File(Request.Query.asString['fname']);
         end;
      end;
      if Request.Query.asString['fname']<>'' then
      begin
         s:=Read;
         Write_File(Request.Query.asString['fname'], s, Response.ContentIn-length(s));
      end;
   end;
   Application.ProcessMessages
end;


This is from your client side DataMod.pas file...

When receiving a large file using very similar code I have to add a sleep(5) after the Write_File procedure otherwise the file is corrupt.

BTW: My components are not set to "multi threaded"
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #5 on: January 09, 2010, 08:11:35 PM »

RTC SDK Client Lesson 1:
http://realthinclient.com/sdkarchive/indexd703.html

RTC SDK File Client demo:
"Demos\File_Client\File_Client.dpr" project in the RTC SDK package

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #6 on: January 09, 2010, 08:21:33 PM »

RTC Server Lesson 3
and Server Lesson 4.

Server Quick Start Example 3+4 source code:
"QuickStart\ServerLesson4\rtcServer4.dpr" in the RTC SDK package.

RTC File Server demo:
"Demos\File_Server\FileServer.dpr" in the RTC SDK package.

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #7 on: January 09, 2010, 09:08:54 PM »

I've now uploaded the exe compiled by using the project "QuickStart\ServerLesson4\rtcServer4.dpr" together with a 22 MB test ZIP file to my old Internet Server, configured the firewall on the Server to open the port used by the rtcServer4 project, started the "rtcServer4" project (it starts listening immediately), then went to my local PC and started the project from "Demos\File_Client", entered my Internet Servers IP address ("Server Address" edit field), entered the Port number ("Server Port" edit field), entered the name of that 22 MB zip file (which is now on the Server inside its "data" folder), checked the "Save to file" checkbox and clicked on the "POST" button. The file was then downloaded to my local PC into the "download" folder. I've then unpacked the received file and there were no errors.

I have tested this several times (deleted the file from the "download" folder before each test to make sure its not the old file) by using different options in the File_Client (Auto-Connect, Blocking, Multi-Threaded, Proxy, WinHTTP), the complete file was always received and the received file would always unpack without errors.

PS. I was using the RealThinClient SDK 3.45

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 16 queries.