#1 2025-12-03 18:02:28

gabrielbhz
Member
Registered: 2024-04-21
Posts: 1

How to disable service timeout only during long database processing?

Hello everyone,

I’m working with Delphi, mORMot 2 and FireDAC, and I have an issue related to service timeouts.

In my system, all business logic is implemented in the database. I use mORMot only as an HTTP layer to access and process data.
In some cases, executing a stored procedure may take a long time. When this happens, I face timeout problems on the mORMot server side, and the service instance is released even though the database processing has not finished.

To work around this, I temporarily disable the global service timeout using:

(RestServer.Services.Index(0) as TServiceFactoryServer).TimeoutSec := 0;

However, this affects all connections using the same service, which is not desirable.

My question:
Is there a way to disable or adjust the timeout only during the execution of a long-running process, without impacting other connections or service calls?

Any guidance or best practices would be greatly appreciated.

Thank you!

Offline

#2 2025-12-03 19:28:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,328
Website

Re: How to disable service timeout only during long database processing?

Don't try to tweak the timeout. It won't work because of the HTTP link itself, and that it would use one thread of the HTTP server thread pool.

Use a dedicated thread for the long process.

Switch to websockets and use the "long work callback" pattern.
See sample https://github.com/synopse/mORMot2/blob … server.dpr

Or switch to a "polling/asking" pattern if you can't use websockets.
With endpoints like "MyRequestStart()" and "MyRequestResult()"  methods, calling MyRequestStart() once but retrying MyRequestResult() every 100-500ms for instance, until it succeeded.

Offline

Board footer

Powered by FluxBB