Jump to content

Occasional access violation while accessing sessions from ServerModule


hari bhandari

Recommended Posts

Hello Everyone, we are sending session info to the server every 10 seconds but the code below occasionally gives us AV's and sometimes even couldn't lock session.We are just sending the string returned by this function to the api and the api handles the rest.

SessionManager.Sessions.ExportSessionsList.Text;

has anyone faced this issue before? and any suggestions to fix this?

We tried Locking sessions to, but the issue was even more freequent.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

We still having this issue, we followed Session List demo and we tried with or without s.Lock;

To detail, we're using a UniThreadTimer for each 10 seconds get all sessions from each Node in HyperServer mode to get all sessions info and handle active sessions for licensing purposes, but we're getting a lot of access violations reported in exceptions log when SessionManager.Sessions.ExportSessionsList.Text cannot take sessions info.

Userstring is set to "could not lock session" when this error is raisen

@Sherzod do you have any clue about that? We're concerned to put our licensing system in production and face some lag or system locks

  • Upvote 1
Link to comment
Share on other sites

We have a UniThreadTimer at ServerModule to get Sessions info from each HyperServer Node and send to our License API, to handle how many users are using the system, since we don't have a native way to get all sessions when in HyperServer mode.

But sometimes we got exceptions with AcessViolations showing that couldn't lock the sessions and Userstring is set to "could not lock session" when this error is raisen

We started from SessionList demo, and we tested in both ways, doing S.Lock or not, the error keeps there randomly.

procedure TUniServerModule.SessionsTimerTimer(Sender: TObject);
var
  SessionText: TStringList;
  s : TUniGUISessions;
begin
  SessionText := TStringList.Create;
  s := SessionManager.Sessions;
  s.Lock; //we tried with lock and without lock, both ways cause the error randomly
  try
    try
      SessionText.Text := SessionManager.sessions.ExportSessionsList.Text;
      SendUniSessionsToLicenseAPI(SessionText.Text); //call a procedure to send Sessions info to our License API
    except
      on E: Exception do
      begin
        Logger.AddLog('LICENSE TIMER ERROR: ' + E.Message);
      end;
    end;
  finally
    SessionText.Free;
    s.Unlock; //we tried with lock and without lock, both ways cause the error randomly
  end;
end;

 

Link to comment
Share on other sites

Thanks for the answer Mr. Farshad

Actually we started our License API calls, following exactly the Session List demo, but we also got the AV errors and UserString is set as "Could not lock session"

So we tried to use ExportSessionsList but both ways sometimes we get same AV error reported in Logs, and show in our License API

image.thumb.png.e6db784a6eda3a156748a916a7766075.png

 

By the way, yes we use more info about sessions, to get more control of our licenses, like Last event, Browser User Agent, IP, etc

And since we cannot get sessions all info using HyperServer mode, it's a important feature for us, because it's the way that we will sell our system, by simultaneous active session licenses.

So we create a License API and a Portal to handle Licenses and let our customers to check who's online

But we're concerned about these errors, so again any tip or good practice would welcome, or at least please check if is some uniGUI error, because I saw some posts with same error but unanswered and seems unsolved

We're growing, today I renewed my subscription and bought more 2 licenses of uniGUI, but we need assistance for this case, because we're concerned about these locks.
@augusto.pellis

image.thumb.png.9a886c0d4f6d85b2d9d8dbcc3560b2e9.png

Link to comment
Share on other sites

  • 2 weeks later...
On 11/4/2022 at 6:10 AM, Oliver Morsch said:

I would call the function 

SendUniSessionsToLicenseAPI(SessionText.Text)

AFTER the s.unlock. So the Sessionlist is only locked for a short time.

Thx for your suggestion Oliver, I posted an old version, currently our code is like this and we still having the issue "Could not lock sessions" sometimes

 

image.png.08152814ac064fc052f8f351f5805d5a.png

Link to comment
Share on other sites

  • 2 weeks later...

Thx again for your contribution Oliver, but as I mentioned above we tried even with or without s.Lock like uniGUI demo, but in both cases we had same issue, sometimer we get "Could not lock sessions" set as UserString, so I think is something from inners of uniGUI to show that could not lock a session for some reason, and we still need to know how to fix it, to use our License API in production, we will launch our application next month and we cannot handle active sessions properly using HyperServer, unfortunatelly.

 

Link to comment
Share on other sites

5 hours ago, lfgarrido said:

Obrigado novamente por sua contribuição Oliver, mas como mencionei acima, tentamos mesmo  com ou sem s.Lock como a demonstração uniGUI, mas em ambos os casos tivemos o mesmo problema, às vezes obtemos "Não foi possível bloquear sessões" definido como UserString, então acho é algo interno do uniGUI para mostrar que não foi possível bloquear uma sessão por algum motivo, e ainda precisamos saber como consertar, para usar nossa API de licença em produção, lançaremos nosso aplicativo no próximo mês e não podemos lidar com sessões ativas usando corretamente o HyperServer, infelizmente.

 

an ugly alternative would be to record the sessions in the database

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...