RTC Forums
November 23, 2024, 09:23:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RtcClientRequest.ContentOut problem  (Read 5025 times)
Max Terentiev
RTC License
***
Posts: 49


« on: February 03, 2017, 12:57:41 AM »

Hi Danijel,

I use RtcMessageClient+RtcDataRequest to upload file to server (RtcMessageServer+RtcDataProvider).

I Use RtcDataRequest.OnDataSent like this:

Code:
procedure TApiUploader.DataSent(Sender: TRtcConnection);
  var
    bSize:int64;
  begin
  with TRtcDataClient(Sender) do
    begin
    if Request.ContentLength>Request.ContentOut then
      begin
      bSize:=Request.ContentLength-Request.ContentOut;
      if bSize>64000 then bSize:=64000;
      Write(Read_File(Request.Info.asText['file'], Request.ContentOut, bSize));
      end;
    end;
  end;

And I got exception: "Error! Answer allready sent for this request." because Request.ContentOut is always 0 it's not updated every Write call so I send more data than expected. But this code works well with RtcHttpClient - with Http CountentOut updates as expected !

It's another limitation of RtcMessageClient ? Or probably bug in RTC ?

p.s. For file downloading I use similar code on server side: Response.ContentOut is used for file reading. So, it's works with RtcMessageServer ! If Response.ContentOut works on server side I expect Request.ContentOut should works on client side ! Or I missing something ?
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: February 03, 2017, 05:06:11 PM »

TRtcMessageClient component's connection provider was missing the required code to increase the "Request.ContentOut" property after every "Write" or "WriteEx" method call. I have fixed this and will be releasing it with the next official RTC SDK update (soon), but you can also apply the fix now in your copy by adding the 2 missing lines in the "rtcMsgCliProv.pas" unit, as shown in this unified diff below:

--- rtcMsgCliProv.pas
+++ rtcMsgCliProv.pas
@@ -431,7 +431,8 @@
   RequestStream.Write(s[0], length(s));
 
   FDataOut:=length(s);
-  LenToWrite:=LenToWrite-FDataOut;
+  Dec(LenToWrite,FDataOut);
+  Request.ContentOut:=Request.ContentOut + FDataOut;
   try
     TriggerDataOut;
   finally
@@ -457,7 +458,8 @@
   {$ENDIF}
 
   FDataOut:=length(s);
-  LenToWrite:=LenToWrite-FDataOut;
+  Dec(LenToWrite,FDataOut);
+  Request.ContentOut:=Request.ContentOut + FDataOut;
   try
     TriggerDataOut;
   finally

Best Regards,
Danijel Tkalcec
Logged
Max Terentiev
RTC License
***
Posts: 49


« Reply #2 on: February 04, 2017, 12:01:52 AM »

Thank you !
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: February 04, 2017, 11:32:47 AM »

You're welcome and thanks for reporting this problem.

This fix is now included in the latest RTC SDK update (v7.75  - just released).

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.