Jump to content
uniGUI Discussion Forums

Sessions blocked on the Hyperserver node from time to time


Recommended Posts

  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

In next build we will add extended session information to above control panel so you will be able to observe why sessions are not freed.

Nothing ?

O problema é outro mesmo, as sessões ficam bloqueadas e o hyperserver não descarta elas.

Posted Images

15 minutes + 5 minutes.

SessionTimeOut is 15 minutes, but when time is out, the server (with websocket) opens a window in the browser with a 5 minutes countdown for closing session with a button to cancel it

Link to post
Share on other sites

The OnSessionTimeOut has a code like this

 

procedure TUniMainModule.UniGUIMainModuleSessionTimeout(ASession: TObject;
  var ExtendTimeOut: Integer);
begin
  if /*Connected to WebSocket*/ then
  begin
    ExtendTimeOut:=UniServerModule.SessionTimeout;
    /*This instruction is to send a GET to a REST service, for the websocket server sends a #TIMEOUT# message to the browser to open a window with CountDown*/
    /*TUniMainModule(TUniGUISession(ASession).UniMainModule).GUID stores the GUID of the websocket client in the browser of the user*/
    EnviarMensajeServidor(TUniMainModule(TUniGUISession(ASession).UniMainModule).GUID,'#TIMEOUT#')
  end;
end;

 

Link to post
Share on other sites

The websocket is created in the OnCreate of MainForm. With a code like this

 

        UniSession.AddJS(ReadString(Size) + #13 + 'socket=new sgcWebSocket(''ws'
          + Copy(UniServerModule.ServidorWebSocket, 5,
          Length(UniServerModule.ServidorWebSocket) - 4) + '/sgc/auth/session/'
          + Token + ''');' + #13 +
          'socket.on(''open'', function(event) { ajaxRequest(' + Name +'.form,''Open'', []);});' + #13 +
          'socket.on(''close'', function(event) { ajaxRequest(' + Name +'.form,''Closed'', [event.message]); });' + #13 +
          'socket.on(''error'', function(event) { ajaxRequest(' + Name +'.form,''Error'', [event.message]); });' + #13 +
          'socket.on(''message'', function(event) { ajaxRequest(' + Name +'.form,''Message'', [event.message]); });');

when the websocket client receives a message send an ajaxRequest to the MainForm with the Message "Message". So simply, i capture the message on the OnAjaxEvent of MainForm.

Link to post
Share on other sites
  • Administrators
24 minutes ago, aristeo said:

The OnSessionTimeOut has a code like this

 


procedure TUniMainModule.UniGUIMainModuleSessionTimeout(ASession: TObject;
  var ExtendTimeOut: Integer);
begin
  if /*Connected to WebSocket*/ then
  begin
    ExtendTimeOut:=UniServerModule.SessionTimeout;
    /*This instruction is to send a GET to a REST service, for the websocket server sends a #TIMEOUT# message to the browser to open a window with CountDown*/
    /*TUniMainModule(TUniGUISession(ASession).UniMainModule).GUID stores the GUID of the websocket client in the browser of the user*/
    EnviarMensajeServidor(TUniMainModule(TUniGUISession(ASession).UniMainModule).GUID,'#TIMEOUT#')
  end;
end;

 

 ExtendTimeOut:=UniServerModule.SessionTimeout;

Each time you call above line, your session will be extended for another 15 minutes. It is quite possible that above code is the reason that your sessions are kept alive.

 

Link to post
Share on other sites
  • Administrators

But your timeout extension code may go into an infinite cycle which may keep sessions indefinitely alive. You need to make sure such a condition will never occur.

BTW, we already have a built-in mechanism to show a timeout window.

Have you reviewed our Session Idle Timeout demo project?

 

Link to post
Share on other sites
  • Administrators
9 minutes ago, aristeo said:

Ok.... I haven't saw that sample. I will implement this, like Session Idle TimeOut and I will inform about the resul. Thanks.

OK.

My recommendation is to avoid using "ExtendTimeOut" to extend session timeout.

Link to post
Share on other sites
  • 2 weeks later...
On 08/10/2020 at 06:16, Farshad Mohajeri said:

É bom ver que seu problema foi resolvido.

Good Morning,

I still have the problem of blocking sessions in my unigui, I am using version 1537 as seen in image 2.

See in image 1 that I selected an executable and it is not using the 0% CPU, I clicked with the right mouse button to find out which folder it was part of, after that in image 2 we can see that there are sessions stuck to more than 10 hours.

I was able to find out that in case an error occurs in the system and the unigui does not manage to show this error and hangs the session, it gets stuck. I was generating a report and it gave some error that it did not show in my error handling, I closed the browser roughly and opened a new system tab, I did it last night for 2 times, after that I stayed with this session Node id = 0 and 1 prey. See that I open the list of sessions and it is empty.

The problem is that the memory consumption of my server is very high and the firebird process is never closed, it is always increasing, see in image 2 how the firebird has high memory consumption.

In image 5 we can see how the machine is working.

Sem título.png

Link to post
Share on other sites
24 minutes ago, Farshad Mohajeri said:

A imagem anexada acima é muito pequena. É difícil ver os detalhes.

Você já tentou definir o parâmetro "recycle_after_idle_seconds" do HyperServer?

I'm sorry, I didn't notice that the image is distorted when you enlarge it,

Where do I set this recycle_after_idle_seconds parameter?

Link to post
Share on other sites
4 minutes ago, Farshad Mohajeri said:

No arquivo CFG do seu hiperservidor. Por favor, veja os documentos:

http://www.unigui.com/doc/online_help/installing-and-configuring-hyp.htm

Am I using the standard, is it correct or can I improve in some way?

[node_recycling]
enabled=1
recycle_after_secs=3600
recycle_after_sessions=0
recycle_after_idle_secs=300
recycle_when_empty=1
recycle_after_idle_seconds=0
 

Link to post
Share on other sites
  • Administrators
1 minute ago, eduardosuruagy said:

Am I using the standard, is it correct or can I improve in some way?

[node_recycling]
enabled=1
recycle_after_secs=3600
recycle_after_sessions=0
recycle_after_idle_secs=300
recycle_when_empty=1
recycle_after_idle_seconds=0
 

recycle_after_idle_secs=300

You can remove above line. It is no longer used.

 

recycle_after_idle_seconds=0

For above line set it to max amount that a session is allowed to remain idle. For example 15 minutes (15x60=900 secs)?

It depends on your application design. What is the max amount of time where a Node may stay idle? Set it to that amount and HyperServer will destroy that Node if it remains idle more than that period.

 

Link to post
Share on other sites
3 hours ago, Farshad Mohajeri said:
3 hours ago, Farshad Mohajeri said:

recycle_after_idle_secs = 300

Você pode remover a linha acima. Não é mais usado.

 

recycle_after_idle_seconds = 0

Para a linha acima, defina-o para o valor máximo permitido para uma sessão permanecer inativa. Por exemplo, 15 minutos (15x60 = 900 segundos)?

Depende do design do seu aplicativo. Qual é a quantidade máxima de tempo em que um nó pode ficar ocioso? Defina-o com esse valor e o HyperServer destruirá esse nó se permanecer inativo por mais do que esse período.

 

= 300

Você pode remover a linha acima. Não é mais usado.

 

recycle_after_idle_seconds = 0

Para a linha acima, defina-o para o valor máximo permitido para uma sessão permanecer inativa. Por exemplo, 15 minutos (15x60 = 900 segundos)?

Depende do design do seu aplicativo. Qual é a quantidade máxima de tempo em que um nó pode ficar ocioso? Defina-o com esse valor e o HyperServer destruirá esse nó se permanecer inativo por mais do que esse período.

 

I will use the recycle_after_idle_seconds = 900 option because my session limit is 10 minutes.

Is it okay if I leave this option recycle_after_idle_secs ?? I have to remove from several files there if it is not a problem for me it would be better.

Link to post
Share on other sites
13 minutes ago, eduardosuruagy said:

Once again I thank you very much for your help, thank you very much !!

BY the way. Everytime you change the parameter do not forget to recycle the IIS app pool or restart your service (in case you use Hyperserver as a windows service).

Link to post
Share on other sites
1 hour ago, RobertoLopes said:

A propósito. Toda vez que você alterar o parâmetro, não se esqueça de reciclar o pool de aplicativos do IIS ou reiniciar seu serviço (no caso de usar o Hyperserver como um serviço do Windows).

Ok, Obrigado pela dica!!

Link to post
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...