You are not logged in.
Pages: 1
In this days I have some problems with the users timeout so I have some questions:
1) Can I use a client application (where I have use setUser to set the user) without have set the user on server? or I need I have an "active user" also on server application.
2) Similar 1): Can I use a client application (where I have use setUser to set the user) when I have set the user on server but the user in server is timeout? or I need I have an "active user" also on server application.
3) Is there a way to know how long is the timeout of a user?
In fact I have this problem: I have set the user timeout to 1440 (a day), however after a small time my client cannot retrive data from server and I need restart the server to work again...
Offline
You can use a client application without any user only if the server is not declared with aHandleUserAuthentication=TRUE.
For security reasons, this is a global parameter.
What you can do is to log as "Guest" user, or define your own user.
The connection problem is something else.
Having to restart the server is not normal at all, you are right.
We need to fix this, without trying to break security.
What is wrong? What does "cannot retrieve data from server" mean? Is there an explicit time out error from the server? Or is the server blocked?
Please enable logs to see what's up, or provide some code to reproduce the issue.
Offline
OK I'll try to explain a little problem with the code.
I use the standard "user definition": Admin, Supervision, User and Guess but I have set Timeout to 1440 for Admin and Supervision.
My server application have a GUI so I run the server with aHandleUserAuthentication=TRUE and use setUser to set the administrtaor user. So the administrator can edit the DB from server application.
On my client I use setUser to set a supervision user (yes I can use the User but for now I use the Supervision).
Both Server and Client application can be reduce to tray bar with a icon. When the user (supervision or admin) open the application from the traybar, my application read a database record to know if it must show a login/password form (this is a option, the administrator can change it).
This is the code:
var
query: string;
TableVersion: TSQLTableJSON;
begin
DatabaseBlocked := True;
query := 'SELECT ID, LoginTray, ProtectionOverview FROM Version WHERE Version.ID ="1"';
TableVersion := Database.ExecuteList([], query);
if TableVersion <> nil then
begin
try
if TableVersion.RowCount > 0 then
begin
if TableVersion.GetAsInteger(1, TableVersion.FieldIndex('LoginTray')) = 0 then
begin
DatabaseBlocked := False;
end;
end;
finally
TableVersion.Free;
end;
end
else
begin
begin
MessageDlgLM('ContLab', MSG_DBNOTCONNECTION, mtError, [mbOK]);
end;
end;
if DatabaseBlocked = True then
begin
LoginForm := TLoginForm.Create(Self);
try
if LoginForm.ShowModal = mrOk then
begin
DatabaseBlocked := False;
end;
finally
LoginForm.Free;
end;
end;
end;
I have disable this options (the login from traybar), however today, after a small time (I don't remeber but I think 1 hour), when I try to open the client I have see the login form. I think because the client cannot retriev the TableVersion.
I have try to close the client and then reopen it without success. So I have close both server and client and reopen them. After this all work without problem.
I think that after a long time my server application don't allow my user to get data from db but I don't understand if the problem is the client or the server. I think the server.
About your last question:
YOU SAID "You can use a client application without any user only if the server is not declared with aHandleUserAuthentication=TRUE."
OK I just know it in fact I set user on my client, but must I set a user at server (for example admin)? And if yes, this user must be active (no timeout)?
Last edited by array81 (2012-03-21 17:38:34)
Offline
OK I'll try to explain a little problem with the code.
My server application have a GUI so I run the server with aHandleUserAuthentication=TRUE and use setUser to set the administrtaor user. So the administrator can edit the DB from server application.
The server application do not need to be authenticated to access the DB.
From the server side, all ORM methods of TSQLRestServer do NOT use any authentication, and have full access to the DB.
query := 'SELECT ID, LoginTray, ProtectionOverview FROM Version WHERE Version.ID ="1"';
While are you still using using SQL in your code?
This could use the ORM version instead, i.e. TSQLRest.Retrieve() or TSQLRest.OneFieldValue() method.
I think that after a long time my server application don't allow my user to get data from db but I don't understand if the problem is the client or the server. I think the server.
Please enable integrated logging to find out the real cause, not just guess.
OK I just know it in fact I set user on my client, but must I set a user at server (for example admin)? And if yes, this user must be active (no timeout)?
See my 1st answer above.
Offline
YOU SAID "While are you still using using SQL in your code? This could use the ORM version instead, i.e. TSQLRest.Retrieve() or TSQLRest.OneFieldValue() method."
Yes but I use SQL with SELECT so I don't think this is a problem, right?
In this case I can replace it, but in other case to create a TSQLTableJSON and then use it on UpdateFromServer.
Offline
OK I will change this point.
But in general I can use SQL and SELECT, right? So I will change it for a better optimitation but it should work.
Offline
Yes, it should work, but you may have issues with some kind of DB engines.
Using the ORM methods is preferred.
The framework documentation states this clearly.
Only use SQL if necessary, for well identified (i.e. after true profiling) performance reasons.
"Premature optimisation is the root of all evil", as Donald Knuth says...
In Donald Knuth's paper: "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."
See also http://blog.synopse.info/post/2011/05/2 … plications
Offline
Pages: 1