Jump to content
sp0987

KeepAliveTimeSec of TSslHttpServer

Recommended Posts

We have project which was migrated from Delphi 7 to Delphi 11. 

 

In delphi7, we used

"ICS - Internet Component Suite - V8 - Delphi 7 to RAD Studio 10.4 Sydney Revised: Dec 17, 2020  Release: V8.65". We didn't face any problem like server stop automatically after certain amount of time.

 

In Delphi 11, we used 

"ICS - Internet Component Suite - V8 - Delphi 7 to RAD Studio 10.4 Sydney Revised: August 22, 2023  Release: V9.0". In this we are facing the server stop problem. 

 

 

Share this post


Link to post

Can you please answer the several questions I have previously asked, rather than just repeating one of the symptoms of your problem? 

 

Angus

 

 

Share this post


Link to post

Am not repeating , am just making things clear so that you can understand the issue. 

 

May I know the questions which I haven't answered you.  

Share this post


Link to post

I'd like to know for what purpose you are using the ICS web server, what application, and why you are trying to disable server timeouts with

 

WebServerSSL.KeepAliveTimeSec := 0;
WebServerSSL.KeepAliveTimeXferSec := 0;

 

Web servers are not supposed to keep idle connections opens unless keep-alive is requested.   The Heartbeat timer should ignore zero timeouts, but I've never tested it, since no-one needs that feature.

 

Also, you sometimes mention the connection being closed, sometimes the web server, which seems highly unlikely. 

 

Angus

 

Share this post


Link to post

Ours is a webserver project developed using Delphi7. It's a service based project and we need internet components in order to meet our demand to connect to the web. We have utilized "Tsslhttpserver and TICSLogger" components in our project.


According to the previous discussion, the server did not disconnect after the idle period; the clients that were connected when the server was opened did.

 

Using our Delphi 7 project, we behave in the same way.

We encountered AV when we moved our project from Delphi 7 to Delphi 11. As a result of AV, we observed that the server and client would also become disconnected. Thus, to address the problem, we considered employing

The values of WebServerSSL.KeepAliveTimeSec and WebServerSSL.KeepAliveTimeXferSec are equal to zero.

However, it didn't resolve our problem.

 

One by one, the clients disconnect in the "TCustomWSocketServer.WMClientClosed" process. Eventually, the client ID sets to "0," freeing the client.

AV in Delphi11 appears when the last client disconnects, the client ID is set to Zero'0', and we attempt to call client.free.

 

 

 

Share this post


Link to post

Thanks for the information, but you have not explained what the clients are doing.  And I'm still confused as to why you think clients being disconnected when idle is a bad thing, that is the design. 

 

If you want idle clients to remain connected, set long KeepAlive timeouts, several hours.  Zero for no disconnect is not documented as a design feature., 

 

The ICS web server is well tested over 20 years, in use on many public web servers, including my own.

 

Angus

 

 

 

Share this post


Link to post

Long-term client connectivity was not my intention.
 The clients become disconnected in accordance with the design, and that is definitely not my problem.

My issue is that "we are receiving AV when the last client disconnects, which causes a server disconnect."

 

image.thumb.png.c29fd9d42cf4b3594e6a8e12ab834e87.png

Share this post


Link to post

If you get an exception in that function, your application has probably already freed the client, although the exception should have happened a few lines higher.  But it could also be memory corruption.

 

If you have recently converted your application from Delphi 7 AnsiStrings to Unicode, I would look very carefully at all your string handling for received data. 

 

Angus

 

Share this post


Link to post

Prior to that line, the client was not free, and I changed the strings to make them compatible. It didn't stop the AV, though.

Any other suggestions?

Share this post


Link to post

Sorry, no simple answer, something your own code is doing is corrupting memory, so the client can not be freed correctly. Or a function being called from the client.  No easy way to find the problem.  Perhaps comment out various parts of the code until the problem disappears to narrow it down. 

 

Angus

 

Share this post


Link to post

Sorry, I don't have the time to debug end user applications, only fix proven reproducible problems in the ICS components.

 

Angus

 

Share this post


Link to post
2 hours ago, sp0987 said:

Any other suggestions?

Put a breakpoint in the client destructor and also on the line where the AV occurs (client.free). And run the application. If the destructor brekpoint is hit before the one on client.free, then try to understand why the client is destroyed before the call to free.

Share this post


Link to post

The destructor didn't hit before the client disconnect.

  

image.thumb.png.cca024fc7d0ecd030ef17d83c11250a3.png 

When the server was opened , 4 clients were connected to the server . And when the server was idle for the keepalivetime sec's, then the clients will be disconnected using the highlighted LOC(FWSocketServer.Disconnect(Cli);). But for the last client the line will be skipped as the if condition fails and then it calls the "procedure TCustomWSocketServer.WMClientClosed(var msg: TMessage);" method using "procedure TCustomWSocketServer.WndProc(var MsgRec: TMessage);"  Here when calling client.free, the AV appears. 

 

In this total execution, the client destructor wasn't called before the client disconnect.

Share this post


Link to post

I would recommend you upgrade to the latest ICS V9.0, there were a number of fixes relating to objects not being freed after exceptions, lots of clean-up, particularly for Win64 servers. 

 

There is no general problem with the ICS web server crashing, the following is from the status page of one of my public ICS web servers, doing SQL queries, REST requests and standard web pages, it just keeps running, until time for Windows Update or a new version:

 

WSocket: TWSocket (c) 1996-2023 Francois Piette V9.1
Server: THttpServer (c) 1999-2023 F. Piette V9.0
Windows Boot Time: 10-Oct-2023 21:54:24
WebAppTelecom Start Time: 10-Oct-2023 22:54:27
Server OS: Windows Server 2019 Standard 1809 Win64 10.0.17763
Compiler: Delphi 11.3 Win64
OpenSSL Version: Static OpenSSL 3.0.11 19 Sep 2023, Legacy Provider Loaded OK
SQL Requests: 49,572
Total Requests: 104,933
Total Connections: 117,470
Max Simultaneous Connections: 60
Total Data Received: 73.7M
Total Data Transmitted: 3.03G
 

Angus

 

 

Share this post


Link to post

The problem was fixed. Objects that are created without initializing to Nil are the source of the issue. It provided AV in the most recent Delphi version, but it functioned in earlier versions.

Thank you for your kind support.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×