RTC Forums
November 10, 2024, 08:49:11 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Header AV  (Read 4406 times)
dev
Newbie
*
Posts: 10


« on: May 25, 2014, 11:32:55 AM »

Hello.

I am doing an exercise to extend the AppClient and AppServer demos with headers.

While there is some success with sending and receiving the header on the server, I am stuck with the following AVs:

First chance exception at $76A2C42D. Exception class Exception with message 'Last header intercepted with new header, before data sent out.'. Process AppClient.exe (10196)
First chance exception at $76A2C42D. Exception class Exception with message 'More Results received than Calls sent.'. Process AppClient.exe (7728)

Hoping someone can show me the right way to overcome this issue.

AppClient:

procedure TForm1.Edit1Change(Sender: TObject);
begin
  with RtcClientModule1 do
  begin

    StartCalls;
    try
      RtcClient.Request['h1'] := 'Hello World!';
      RtcClient.WriteHeader;
      // Call the Add function
..
..
    finally
      // Post all prepared calls
      Post;  // causes AV
      end;


AppServer:

procedure TForm1.RtcDataProvider1CheckRequest(Sender: TRtcConnection);
var Srv:TRtcDataServer absolute Sender;
begin
 if Srv.Request.Complete then
    showmessage(srv.Request['h1']);
//    accept;
end;

Thanks & regards
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: May 25, 2014, 01:52:39 PM »

You are getting exceptions raised by the RTC SDK to warn you, because you are trying to bend the components to do something they were not designed for.

First off, you should NEVER try to use any properties or methods directly on the TRtcHttpClient component outside of events triggered by those components. TRtcDataRequest and TRtcClientModule components have their own public and published properties and methods which were designed for use outside of RTC events, but all the properties and methods on the TRtcHttpClient components may ONLY be used from inside RTC events. Nowhere else.

Secondly, you can NOT simply inject a HTTP header into a request which is supposed to be used for sending remote function calls. When using RTC remote functions through the TRtcClientModule component, the component itself will be creating and preparing a new HTTP header object before sending the request and content body containing remote function calls.

If you want to manually design your own HTTP requests with custom HTTP headers containing structured data, you need to use the TRtcDataRequest component and NOT the TRtcClientModule on the Client side.

Best Regards,
Danijel Tkalcec
Logged
dev
Newbie
*
Posts: 10


« Reply #2 on: May 25, 2014, 03:17:14 PM »

I see where I was confusing things.  Sticking to just TRtcDataRequest all works well.

Thanks for your help Danijel.
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.023 seconds with 17 queries.