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

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: First tests with RTC  (Read 5268 times)
MirkoC
RTC Expired
*
Posts: 3


« on: November 15, 2016, 10:02:31 PM »

Hi,

I'm pretty new with RTC components and like every newbie I first tried to reproduce the samples projects from the classroom on website.
After first success with basic connection project beween server and client I'm hanging now on the DB access sample, but not using SQLite but MySQL.

While the launch of the server wasn't a problem, the creation of the client is confusing me a little bit. I tried to follow the logic of the components and after starting the server (listening active), the launched client gives me an exception on clicking on the connect and fetch button, giving back "PostRequest: Client connection undefined" raised by rtcClientModule.Call(rtcResult);

Here the full procedure:
procedure TFormMain.ButtonClick(Sender: TObject);
begin
  // Set Client Connection Properties
  rtcClient.ServerAddr := ServerAddress.Text;
  rtcClient.ServerPort := ServerPort.Text;
  // Disconnect the Datasource from the Dataset
  DataSource.DataSet := nil;
  rtcClientModule.Prepare('GetLanguageData');
  rtcClientModule.Call(rtcResult);
end;


where GetLaungageData is the function defined in the server.

What is blocking my client to connect to the server?

Thanks for helping me understand the logic of the single components...

M.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: November 16, 2016, 09:30:50 AM »

The error message says that you did NOT assign a Client connection (TRtcHttpClient component) to the "Client" property of your TRtcClientModule component.

In code, this would be ...

rtcClientModule.Client := rtcClient;

Also, make sure to set the AutoConnect property to TRUE on the TRtcHttpClient component, if you do NOT plan on manually calling Connect and Disconnect.

Best Regards,
Danijel Tkalcec
Logged
MirkoC
RTC Expired
*
Posts: 3


« Reply #2 on: November 17, 2016, 02:17:43 AM »

Thanks Danijel. Issue solved!

I'm working through the samples and begin to understand the logic of your components.
Looking powerful, congrats...
After solving this issue I proceed with mixing some shown features and I come to this one...

Server is running and listening...
Launching the Client I push a Login button invoking this

procedure TFormLogin.Btn_LoginClick(Sender: TObject);
begin
  with RtcClientModule do
  begin
    with Data.newFunction('Login') do
    begin
      asString['name'] := UserName.Text;
    end;
    Call(RtcResult);
  end;
end;


and get an exception when debugging on:

function TRtcDataClient.RequestCount: integer;
  begin
  FCS.Acquire; <- here
  try
    if assigned(FRequestList) then
      Result:=FRequestList.Count
    else
      Result:=0;

    if assigned(FActiveRequest) then
      Result:=Result+1-FRequestSkipped;
  finally
    FCS.Release;
    end;
  end;


It seems that no active request is present and I compared the settings with your demos. Running the compiled file doesn't give me an exception, but doesn't also call the function.

In the client I have HTTPClient, a ClientModule and a Result
In the server I have a HTTPServer, a ServerModule, a FunctionGroup and the Function

Thank you for introducing me and sorry for al this simple questions Smiley

Regards
M.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: November 17, 2016, 01:18:45 PM »

Without more information, I can only guess that ...

A) you are trying to use the TRtcHttpClient component (or another RTC component using that TRtcHttpClient component, like TRtcClientModule) after destroying that TRtcHttpClient component, or ...

B) you have destroyed a TRtcHttpClient component from inside an event triggered by the same and/or linked RTC component, which resulted in TRtcHttpClient component and any objects owned by the TRtcHttpClient component to be destroyed, before the component could finish executing any code that has to be executed after your event finishes (for example, check if there are any more requests that need to be sent).

If you have NOT destroyed the TRtcHttpClient component or the Form/DataModule containing the component before the exception happened, then I will need more detailed information about the way you are using RTC components, because the only exception you can get at that line is an Access Violation, which can ONLY happen if the TRtcHttpClient components destructor has already been executed by the time that line of code is reached.

Best Regards,
Danijel Tkalcec
Logged
MirkoC
RTC Expired
*
Posts: 3


« Reply #4 on: November 17, 2016, 09:25:52 PM »

Thanks Daniel.
A) was the issue... in fact I placed the client components in a login form showed in modal form before creating the main application form.
Now the components react exactly how they should.
Great support, thanks!!  Wink
M.
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.