Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Double Rest server authentication may be causing a problem.


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jun 21, 2016 10:54 AM Last Post By: LAURENCE KILLEN
LAURENCE KILLEN

Posts: 41
Registered: 2/20/00
Double Rest server authentication may be causing a problem.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 6, 2016 2:00 PM
I've written a Rest Server/Client application in Delphi XE10. It runs perfectly well on the development server but when it is placed on the Production server, it returns 500s. The production server is 4 VMs behind a load balancer. As a side note, I do not have direct access to the production server. It is entirely controlled by the parent company and I am limited to a much simpler Dev server.

One thing I have noticed on Dev and even on my stand alone server is that the initial authentication makes two sequential calls. The first has empty authentication parameters. I sent the results to a memo as:
3:19:18 PM | DSAuthenticationManager1UserAuthenticate
Sender TDSAuthenticationManager
Protocol datasnap Context rest/ User Password
Valid 0
3:19:18 PM | DSAuthenticationManager1UserAuthenticate
Sender TDSAuthenticationManager
Protocol datasnap Context rest/ User 18039 Password 20028876AEA073B75ABBAF498982198A20D41F41
Valid -1

On the Dev server, this returns a 401 on the first GetServerMethods call:
constructor TClientModule2.Create(AOwner: TComponent);
var
IniFile : TIniFile;
Path: String;
begin
inherited;
Path:= ExtractFilePath(Application.ExeName);
IniFile := TIniFile.Create(Path+'clientSettings.ini') ;
fHost := IniFile.ReadString('ServerSettings','Host','localhost');
fPort := IniFile.ReadInteger('ServerSettings','Port',80);
fContext := IniFile.ReadString('ServerSettings','context','datasnap/');
furlpath := IniFile.ReadString('ServerSettings','urlpath','');
frmMain.fKmzUrlPath := IniFile.ReadString('DataSettings','kmzPath','');
DSRestConnection1.LoginProperties.UserName := frmMain.ActiveEmpID;
DSRestConnection1.LoginProperties.Password := frmMain.ActivePassword;

frmMain.StatusBar1.Panels[4].text := fHost+':'+IntToStr(fPort);
DSRestConnection1.Host := fHost;
DSRestConnection1.Port := fPort;
DSRestConnection1.Context:= fContext;
DSRestConnection1.UrlPath:= furlpath;

FreeAndNil(IniFile);
FInstanceOwner := True;
end;

destructor TClientModule2.Destroy;
begin
FServerMethods1Client.Free;
inherited;
end;

function TClientModule2.GetServerMethods1Client: TQtrMinClient;
begin
if FServerMethods1Client = nil then
FServerMethods1Client:= TQtrMinClient.Create(DSRestConnection1, FInstanceOwner);
Result := FServerMethods1Client;
end;

I am going after the "empty authentication" call since I figure it may be causing the 500 on the production server.

procedure TWebModule1.DSAuthenticationManager1UserAuthenticate(Sender: TObject;
const Protocol, Context, User, Password: string; var valid: Boolean;
UserRoles: TStrings);

begin

if ((User <> '') and (Password <> '')) then
begin
with qryLogin do
begin
close;
ParamByName('empID').Value := StrToInt(User);
ParamByName('password').Value := Password;
open;
valid := not(IsEmpty);
close;
end;
end
else
valid := false;

{$IFDEF STANDALONE}
Form1.Memo1.Lines.Add(TimeToStr(Time())+' | '+'DSAuthenticationManager1UserAuthenticate');
Form1.Memo1.Lines.Add('Sender '+Sender.ClassName);
Form1.Memo1.Lines.Add('Protocol '+Protocol ' Context ' Context + ' User '+ User +' Password '+Password);
Form1.Memo1.Lines.Add('Valid '+booltostr(Valid) );
{$ENDIF}

end;

I am not sure if it is related but I have nowhere else to turn.

first call to server:
function TfrmMain.GetAreasByMap(MapID: Integer): Boolean;
var
LDataSetList: TFDJSONDataSets;
begin
try
// It empties the memory table of any existing data before adding the new context.
FDmemMapList.Close;

// Get dataset list containing QtrMinutes
LDataSetList := ClientModule2.ServerMethods1Client.GetAreasByMap(MapID);
FDmemMapList.AppendData(TFDJSONDataSetsReader.GetListValue
(LDataSetList, 0));

FDmemMapList.Open;
fActiveState := FDmemMapList.FieldByName('state').AsString;
except
on E: Exception do
begin
MessageDlg
('There was a problem connecting to the QtrMinApi server. It has returned an error message: '
+ E.Message + #10#13 +#10#13 + ' Please contact UtiliQuest IT for assistance.',
mtError, [mbOK], 0);

result := false;
end;
end;

Edited by: Springer Rider on Jun 6, 2016 4:04 PM

LAURENCE KILLEN

Posts: 41
Registered: 2/20/00
Re: Double Rest server authentication may be causing a problem.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 21, 2016 10:54 AM   in response to: LAURENCE KILLEN in response to: LAURENCE KILLEN
got it figured
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02