#1 2024-10-14 10:41:29

DelphiSoul
Member
Registered: 2024-10-14
Posts: 1

How to increase rest server object life time

Hi, thanks for the great work and sorry for my English.

I need to implement server object with very expensive (time consuming) creation, wich i suppose to reuse from call to call. Also its not thread safe, so I believe the sicPerThread creation model is suitable.
I also need a client for this server implemented in Delphi 7.

I encountered two issues:

a) The KeepAliveTimeout is hardcoded to 30 sec in module mormot.rest.http.server:

 

fHttpServer := HTTPSERVERSOCKETCLASS[aUse].Create(fPort, HttpThreadStart, HttpThreadTerminate, TrimU(fRestServerNames), aThreadPoolCount, 30000, hso)

  Session terminates and destroys my object after 30 sec while i need something about one-two hours. Maybe I'm doing something wrong? Why hardcode?


b) Client compiled with Delphi 7 terminates the previous session for each call (while the same code, compiled with Delphi 10.4 works fine).

Do you have any suggestions to achieve my goals?

Thank You.

Offline

#2 2024-10-14 13:37:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,686
Website

Re: How to increase rest server object life time

The sicPerThread is not what you need. This option will just map the HTTP connection threads to the instance, so after 30000 milliseconds (see your parameter), then the instance is released.
It uses the HTTP connection threads. So you can't use it for long-standing process.

I would put the long-threading processing in a separated thread.
Or, even better, create one thread per process, and let the system deal with it.
If you process is more than a few seconds, then a dedicated thread makes sense. Your code would be also cleaner.

Offline

Board footer

Powered by FluxBB