RTC Forums
November 24, 2024, 12:05:10 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Exception "No data defined. Use the Data property before "Call" in rtcCliModule  (Read 4391 times)
ManfredPfeiffer
RTC License++
*****
Posts: 14


« on: May 18, 2014, 07:33:22 PM »

Danijel,
I delivered a client/server application to customers and I am haunted by above exception which occurs when you send several requests in a short timeframe. Code excerpt:

with RtcClientModule1 do try
  begin
    with Prepare('TERMINATOR') do
      begin
        if l0(edit2.Text) then
        asString['name']:='Huh'  // Was gibts Neues
        else
          begin
            asString['name']:=edit2.Text; edit2.Text:='';
          end;
        asString['nutzer']:=person;
        with Execute(True,15000) do // execute remote function (free result before next call; call timeout 5000 miliseconds).
          ergebnis:=asstring;
        verarbeiten(self,ergebnis);
      end;
  end;
except
  on e: exception do

If a new requests is sent after the response has been received everything is fine.
Can you provide any insight into this issue?

Kind regards,
Manfred 
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: May 18, 2014, 08:39:27 PM »

The exeption you are getting means that you are using Execute or Call before the Data object was prepared, or after it has already been used by another Execute or Call method call. This can happen if you are using the Execute method from a background thread, or from an event triggered by RTC components, or if you allow user interraction during the Execute method (to keep the appearance of non-blocking execution, even though the code should be executing in blocking mode). In other words, if you have any events which can execute code using the Call or Execute method, while waiting for the result.

By default, the Execute method allows Message Processing while waiting for a Result. This means that events can be triggered while waiting. While this is good if you have made sure that nothing can be triggered which would interrupt your Execute call, it can also be the problem you are facing, because could you end up with unexpected user-triggered events. To disable message processing in the Execute method, you can use the Execute with FALSE as the 3rd paremeter, like this:

with Execute(True,15000,FALSE) do ...

Alternatively, if you are always using a TRtcHttpClient component in blocking mode, for example by using the Execute method instead of the Call method, and you want to make sure that your Execute methods won't be interrupted by user actions, I would recommend setting the Blocking property of the TRtcHttpClient component to TRUE and leaving the MultiThreaded property FALSE. When you do that, every Execute call will be truly blocking. No message loops, no way for another event to interrupt the Execute method call.

By default, TRtcHttpClient component is designed to work in asynchronous even-driven mode. When you use the Execute method in that mode, the Execute method will be emulating blocking mode by implementing a message loop and waiting for the response from the Server. If there are any events that could trigger while this loop is still running, before the result was received, you can end up with code being injected inside that waiting loop and thus a new Execute call being made before the last one completed execution.

I hope that helps.

Best Regards,
Danijel Tkalcec
Logged
ManfredPfeiffer
RTC License++
*****
Posts: 14


« Reply #2 on: May 20, 2014, 06:30:35 AM »

Thank you very much Danijel, for this information and clarification - will have to wait until next weekend before I can try it out...
Kind regards,
Manfred
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.025 seconds with 17 queries.