Hello,
In my Delphi application I am using a TROHttpServer.
I am returning a PDF using a method like this
Result := TROHttpApiResult.Create(HTTP_200_code, id_ContentType_application_pdf, ‘’, False);
When I have many requests, my application is closed.
This request can take a few seconds to be executed and in that time I receive other requests of the same type.
I think it may be something with the TROThreadPool.
How could I increase or change it to receive many requests and not close my application?
Would this be happening because of the exception that is generated by the number of threads x queue?
Thanks
EvgenyK
(Evgeny Karpov)
February 6, 2025, 8:15am
2
Hi,
You can change these properties of ROHTTPServer.ThreadPool :
You can just increase each parameter twice for testing.
–
I’d suggest to launch your server in debugger and see actual error why your server is closing.
I made this change, doubling the default values. The connection is still closed and is opened after this change.
FROServerWeb.ThreadPool.MaxQueue := 100;
FROServerWeb.ThreadPool.MaxThreads := 20;
FROServerWeb.ThreadPool.PoolThreads := 10;
After this change, the server no longer responds to requests.
Is there an additional command missing to apply these values?
EvgenyK
(Evgeny Karpov)
February 6, 2025, 12:05pm
4
Hi,
Have you applied these changes before FROServerWeb.Active := True;
?
Can you catch original error that causes closing your server with standard values of TROThreadPool properties?
Yes, see the block where I initiate these changes.
UELITON_ALVES_FUTURA:
LogInfo('Iniciando Servidor Web para o SisPetro App');
try
//StopServerWeb;
{$IFDEF SERVIDOR_INDY}
interfaceWebStop;
{$ELSE}
// para poder copiar arquivos até 10m
FROServerWeb.Server.MaxPostData := 101024 1024;
FROServerWeb.ThreadPool.MaxQueue := 100;
FROServerWeb.ThreadPool.MaxThreads := 20;
FROServerWeb.ThreadPool.PoolThreads := 10;
{$ENDIF}
if dados.porta > 0 then begin
FROHttpApiDispatcher.ApiHost := 'localhost:' + Trim( IntToStr(dados.Porta) );
end;
FROServerWeb.Port := dados.porta;
FROServerWeb.Active := True;
except
on E: Exception do begin
LogErro('Não foi possível iniciar o Serviço Web. Erro: ' + E.Message);
end;
end;
end;
But I still can’t capture the location of this exception. With each error, the application stops at a different point.
EvgenyK
(Evgeny Karpov)
February 6, 2025, 1:02pm
6
Hi,
post several call stacks - they should have something common.
note: You can drop email to support@ for keeping this in privacy
Ok, I’ll try to get the data to send.
But why isn’t my ThreadPool change working?
I think I need to increase my queue.
EvgenyK
(Evgeny Karpov)
February 6, 2025, 1:27pm
8
Hi,
lets see original error. it can be isn’t related to thread pool settings…
About this topic (post several call stacks) where would I get this information from since the application just closes.
Is there any procedure in TROHTTPServer or property that I can configure to log this data?
EvgenyK
(Evgeny Karpov)
February 6, 2025, 2:50pm
10
Hi,
just start your server in IDE debugger.
when exception is happened, IDE debugger will stop program and you can grab call stack from IDE.
also 3rd party libraries like EurekaLog, madExcept, etc are present.
I have returned my application to its original point.
After 10 minutes of processing requests it is being terminated.
Below is the memory stack (3 tests)
:00c122b8 InitWndProc + $10
:7685182b user32.AddClipboardFormatListener + 0x4b
:76847f1a ; C:\Windows\SysWOW64\user32.dll
:76847b30 ; C:\Windows\SysWOW64\user32.dll
:76850579 ; C:\Windows\SysWOW64\user32.dll
:77c356cd ntdll.KiUserCallbackDispatcher + 0x4d
:76840077 ; C:\Windows\SysWOW64\user32.dll
:7683ff48 user32.CreateWindowExW + 0x38
:0099d198 CreateWindowEx + $44
:00b0e8f3 TCustomMemo.CreateWindowHandle + $BF
:00c1b7ab TWinControl.CreateWnd + $11B
:00b0da7f TCustomEdit.CreateWnd + $27
:00b0e94e TCustomMemo.CreateWnd + $A
:0162aceb TppRichEdit.CreateWnd + $27
:00c1bd58 TWinControl.CreateHandle + $1C
==================================================
:00c122b8 InitWndProc + $10
:7685182b user32.AddClipboardFormatListener + 0x4b
:76847f1a ; C:\Windows\SysWOW64\user32.dll
:76847b30 ; C:\Windows\SysWOW64\user32.dll
:76850579 ; C:\Windows\SysWOW64\user32.dll
:77c356cd ntdll.KiUserCallbackDispatcher + 0x4d
:76840077 ; C:\Windows\SysWOW64\user32.dll
:7683ff48 user32.CreateWindowExW + 0x38
:0099d198 CreateWindowEx + $44
:00b0e8f3 TCustomMemo.CreateWindowHandle + $BF
:00c1b7ab TWinControl.CreateWnd + $11B
:00b0da7f TCustomEdit.CreateWnd + $27
:00b0e94e TCustomMemo.CreateWnd + $A
:0162aceb TppRichEdit.CreateWnd + $27
:00c1bd58 TWinControl.CreateHandle + $1C
:00a59b30 TStrings.LoadFromStream + $8
==================================================
:00c122b8 InitWndProc + $10
:7685182b user32.AddClipboardFormatListener + 0x4b
:76847f1a ; C:\Windows\SysWOW64\user32.dll
:76847b30 ; C:\Windows\SysWOW64\user32.dll
:76850579 ; C:\Windows\SysWOW64\user32.dll
:77c356cd ntdll.KiUserCallbackDispatcher + 0x4d
:76840077 ; C:\Windows\SysWOW64\user32.dll
:7683ff48 user32.CreateWindowExW + 0x38
:0099d198 CreateWindowEx + $44
:00b0e8f3 TCustomMemo.CreateWindowHandle + $BF
:00c1b7ab TWinControl.CreateWnd + $11B
:00b0da7f TCustomEdit.CreateWnd + $27
:00b0e94e TCustomMemo.CreateWnd + $A
:0162aceb TppRichEdit.CreateWnd + $27
:00c1bd58 TWinControl.CreateHandle + $1C
EvgenyK
(Evgeny Karpov)
February 7, 2025, 6:05am
12
Hi,
This error isn’t related to Remoting SDK.
Looks like you have lack of system resources
I think, you should change your server to x64 bit and retest.
This error may go away.