RemObjects SDK Client behaves differently on Android compared to Win32

Hello,

I have an application that talks to a RemObjects SDK server on a PC. The Server is an older version of RO SDK - 6.x - and was written in Visual Studio 2008 / C#. The client application is written in Delphi 10.2 Tokyo using the latest RO SDK.

When the connection to the server drops the client should set the “Weight” variable to -1 and attempt to reconnect to the server. On the PC this works perfectly and it takes 1-2 seconds for it to disconnect when the connection is lost. When the connection is restored it takes 1-2 seconds for the weight to start updating again.

On an Android tablet it takes literally minutes for the Weight to go to -1 indicating the connection was lost. When I start the server up again it can take minutes for the client to reconnect.

The client code is listed below.

{ TScaleThread }

procedure TScaleThread.Connect;
begin
  try
    if URL = '' then
      exit;

    ROMessage := TROBinMessage.Create;
    ROChannel := TROIndyHTTPChannel.Create(nil);
    RORemoteService1 := TRORemoteService.Create(nil);

    ROChannel.TargetUrl := URL;

    RORemoteService1.Channel := ROChannel;
    RORemoteService1.Message := ROMessage;

    fScaleSoftService := (RORemoteService1 as IScaleSoftService);

    fConnected := true;
  except
    on E: Exception do
    begin
      Disconnect;
    end;
  end;
end;

procedure TScaleThread.Disconnect;
begin
  try
    fConnected := False;
    fWeight := -1;

    if Assigned(fScaleSoftService) then
    begin
      fScaleSoftService := nil;
      RORemoteService1.Free;
      ROChannel.Free;
      ROMessage.Free;
    end;
  except
    on E: Exception do
      ShowMessage(E.Message);
  end;
end;

procedure TScaleThread.Execute;
begin
  inherited;

  while not Terminated do
  begin

   try
      if Connected then
      begin
        if Assigned(fScaleSoftService) then
          fWeight := fScaleSoftService.GetWeight(0);
      end
      else
        Connect;
    except
      fWeight := -1;
      Disconnect;
    end;

    Sleep(500);
  end;

  Disconnect;
end;

try to change timeouts on TROIndyHTTPChannel, probably it helps.


your code can be simplified to

procedure TScaleThread.Execute;
begin
  inherited;
  while not Terminated do
  begin    
    try
      if URL <> '' then
        fWeight := CoScaleSoftService.Create(URL).GetWeight(0)
      else
        fWeight := -1;
    except
      fWeight := -1;
    end;
    Sleep(500);
  end;
end;

if you were using this code, would it work better?

The time out worked, thank you!