View Issue Details

IDProjectCategoryView StatusLast Update
0038374FPCFCLpublic2021-01-30 14:53
ReporterSoner Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Platformwin64OSWindows 10 prof 64 Bit 
Product Version3.2.1 
Summary0038374: Possible bug, TFPHTTPServer hangs after some day and doesn't respond any clients.
DescriptionSometimes the TFPHTTPServer does not close client connection. When the frozen connections reachs count of TFPHTTPServer.QuesSIze then the server does not respond connections.
Look at frozen connection from picture it is me yesterday. I closed browser, switched to cellphone connection, at home to the wlan and it still show this connection.

There is often 'No REQUEST_METHOD passed from server.' exception, without some reason.
Steps To ReproduceStart the example project and let it over some days running.
Additional InformationI asked here questions about this error:
https://forum.lazarus.freepascal.org/index.php/topic,51178.0.html
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

Soner

2021-01-19 16:13

reporter  

frozenconnection.jpg (140,033 bytes)   
frozenconnection.jpg (140,033 bytes)   

Soner

2021-01-19 16:42

reporter   ~0128427

Here is small application to download files in loop from local server.

'No REQUEST_METHOD passed from server.' is caused when you enter in firefox something like this: http://localhost/something?..
after typing ?.
Then the error appears random.

Start debugserver before httpserver.
getfromlocalhost.zip (127,502 bytes)

Soner

2021-01-21 18:27

reporter   ~0128467

State update:
My public test server is running since last Friday. The only frozen connection is mine from picture above.
I must say that my public server is only available in west and central european countries. I blocked all other countries with windows firewall, especially hacker countries like USA, China, Russia and so on.
I will investigate further and if I find any valuable information for the developer I will write it here.

Michael Van Canneyt

2021-01-21 20:13

administrator   ~0128469

I think the problem is that the recv/read calls work without timeout.
I will put a timeout on the socket, so these calls will timeout, and the sockets will be released.

Soner

2021-01-22 12:06

reporter   ~0128483

State update:
After EAccessViolation server does not respond.
Look at pictures.

This time It looks like the frozen connections came after exception, because the ip adresses from these are not in debugview.
This is my HandleRequesError function:


procedure TTestHTTPServer.HandleRequestError(Sender: TObject; E: Exception);
begin
  SendDebugEx(DateToStr(date)+' '+TimeToStr(now)+' _ REQUESTERROR: '+E.ClassName+'-'+E.Message,dlError); //call first
  inherited HandleRequestError(Sender, E);
end;

This is the original:
procedure TFPCustomHttpServer.HandleRequestError(Sender: TObject; E: Exception);
begin
  If Assigned(FOnRequestError) then
    try
      FOnRequestError(Sender,E);
    except
      // Do not let errors in user code escape.
    end
end;

Maybe not handled EAccessViolation-Exception stops the server?
Why is EAccessViolation-Exception thrown here by some connections?

Many connections are trying to use well known security hole frome other web apps or server. Their connection parameter contains special characters or not normal parameter standard.

I will change HandleRequestError and set Server.QueueSize very high and report here again.

Soner

2021-01-25 22:07

reporter   ~0128589

Last edited: 2021-01-25 22:08

View 2 revisions

The server stopped to respond on sunday, worked from friday afternoon to sunday afternoon.
Last entry in the debugview is again EAccesViolation exception.
This time was the Server.QueueSize higher than frozen connection count.
My test server is same as from above. (fphttpserverdemox-pub.zip)

Soner

2021-01-30 14:53

reporter   ~0128674

State update:
This week the server runned only 8 Hours, last entry in Debugview is again EAccesViolation exception.
It did not respond to requests. I let the server running because there was only 7 frozen connections, Server.Queuesize is over 100.
Today there are 74 connections. The incoming requests are connecting with the server, but the server does not answer.
I think the source of problem is the EAccesViolation exception.
I searched in sources from the fcl-web folder for EAccesViolation, but I could not found it.

Issue History

Date Modified Username Field Change
2021-01-19 16:13 Soner New Issue
2021-01-19 16:13 Soner File Added: frozenconnection.jpg
2021-01-19 16:13 Soner File Added: fphttpserverdemox-pub.zip
2021-01-19 16:42 Soner Note Added: 0128427
2021-01-19 16:42 Soner File Added: getfromlocalhost.zip
2021-01-19 22:39 Michael Van Canneyt Assigned To => Michael Van Canneyt
2021-01-19 22:39 Michael Van Canneyt Status new => assigned
2021-01-21 18:27 Soner Note Added: 0128467
2021-01-21 20:13 Michael Van Canneyt Note Added: 0128469
2021-01-22 12:06 Soner Note Added: 0128483
2021-01-22 12:06 Soner File Added: debugview-scrshot-20210122-cens-text.jpg
2021-01-22 12:06 Soner File Added: frozenconnections-20210122-censored.jpg
2021-01-25 22:07 Soner Note Added: 0128589
2021-01-25 22:08 Soner Note Edited: 0128589 View Revisions
2021-01-30 14:53 Soner Note Added: 0128674