Recent

Author Topic: TFPHTTPServer doesn't respond next day.  (Read 4468 times)

Soner

  • Sr. Member
  • ****
  • Posts: 318
TFPHTTPServer doesn't respond next day.
« on: August 24, 2020, 12:28:53 pm »
Hello,
I created webapp with TFPHTTPServer. My app-server does not respond after a while.
Sometimes it shows the exception 'No REQUEST_METHOD passed from server.'.
Does anyone know the solution?


I uploaded a test program. I started testprogramm last friday, then it stopped to respond saturday afternoon.

Soner

  • Sr. Member
  • ****
  • Posts: 318
Re: TFPHTTPServer doesn't respond next day.
« Reply #1 on: August 30, 2020, 03:46:58 pm »
Isn't anyone using fphttpserver?

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
Re: TFPHTTPServer doesn't respond next day.
« Reply #2 on: August 30, 2020, 05:29:48 pm »
I do. Did you try the example?
But I am sure they don't want the Trumps back...

Leledumbo

  • Hero Member
  • *****
  • Posts: 8785
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TFPHTTPServer doesn't respond next day.
« Reply #3 on: August 30, 2020, 09:17:00 pm »
Sometimes it shows the exception 'No REQUEST_METHOD passed from server.'.
Should be internal exception only, never goes out to the client.
I uploaded a test program. I started testprogramm last friday, then it stopped to respond saturday afternoon.
I cannot confirm. I run an even more complex app than this, has both HTML and API endpoints and running 24/7 with MySQL backend. Never goes down. There might be OS influence or something else. When it stops responding, can you confirm that the port it binds to is still open?

Soner

  • Sr. Member
  • ****
  • Posts: 318
Re: TFPHTTPServer doesn't respond next day.
« Reply #4 on: August 31, 2020, 05:42:40 pm »
I do. Did you try the example?
Which example? Do you mean from "fpc\source\packages\fcl-web\examples\httpserver", my example and app build up on this example.

Maybe I should use libmicrohttp. GNU things are mostly more matured than fpc things. This example ist build on GNU-Libmicrohttp, I will test it this week:
fpc\3.2.0\source\packages\fcl-web\examples\simpleserver


I uploaded a test program. I started testprogramm last friday, then it stopped to respond saturday afternoon.
I cannot confirm. I run an even more complex app than this, has both HTML and API endpoints and running 24/7 with MySQL backend. Never goes down. There might be OS influence or something else. When it stops responding, can you confirm that the port it binds to is still open?
I don't think it is OS thing, the computer is only for this server app. When I next day restrat the server-app, it works without error.
What is your server class, TFPHTTPServer, TCustomMicroHTTPApplication, TCustomHTTPApplication?

I must say, it is public server, it has ip4 adress. Sometimes it is scanned by a ip4-scanner.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8785
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TFPHTTPServer doesn't respond next day.
« Reply #5 on: August 31, 2020, 08:31:56 pm »
I don't think it is OS thing, the computer is only for this server app. When I next day restrat the server-app, it works without error.
What is your server class, TFPHTTPServer, TCustomMicroHTTPApplication, TCustomHTTPApplication?

I must say, it is public server, it has ip4 adress. Sometimes it is scanned by a ip4-scanner.
I don't use the custom class, I just the ready to use THTTPApplication. It's reverse proxified by nginx as we use the same SSL termination point across all services.

Soner

  • Sr. Member
  • ****
  • Posts: 318
Re: TFPHTTPServer doesn't respond next day.
« Reply #6 on: August 31, 2020, 09:51:14 pm »
I don't use the custom class, I just the ready to use THTTPApplication. It's reverse proxified by nginx as we use the same SSL termination point across all services.
THTTPApplication is  TCustomHTTPApplication.
Sorry I did'nt understand it, are you using fastcgi application with nginx?
I wrote a basic fastcgi app for nginx, that executes pascal script apps.

PierceNg

  • Sr. Member
  • ****
  • Posts: 398
    • SamadhiWeb
Re: TFPHTTPServer doesn't respond next day.
« Reply #7 on: September 01, 2020, 07:08:12 am »
Maybe I should use libmicrohttp. GNU things are mostly more matured than fpc things. This example ist build on GNU-Libmicrohttp, I will test it this week:
fpc\3.2.0\source\packages\fcl-web\examples\simpleserver

Remember Pascal is not C, meaning the the rest of fcl-web and your application talks to libmicrohttpd via fcl-web's libmicrohttpd wrapper written in ... Pascal.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8785
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TFPHTTPServer doesn't respond next day.
« Reply #8 on: September 01, 2020, 10:29:59 am »
Sorry I did'nt understand it, are you using fastcgi application with nginx?
No, I use the the embedded HTTP server via THTTPApplication with nginx in front of it (proxy_pass directive in nginx, not fastcgi_pass).

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
Re: TFPHTTPServer doesn't respond next day.
« Reply #9 on: September 01, 2020, 02:30:12 pm »
Which example? Do you mean from "fpc\source\packages\fcl-web\examples\httpserver", my example and app build up on this example.
Well, just for you I have the example running for neigh 1,5 day , so more than 24 hours and counting...
(On Linux) I might be wrong but if you base something on working code and it does not work anymore, where's the blame?
« Last Edit: September 01, 2020, 02:32:09 pm by Thaddy »
But I am sure they don't want the Trumps back...

Soner

  • Sr. Member
  • ****
  • Posts: 318
Re: TFPHTTPServer doesn't respond next day.
« Reply #10 on: September 02, 2020, 10:40:55 am »
@leledumbo
Thanks for the information. Maybe I should do same.
My program was connected to four IP addresses when it didn't respond. According to abuseipdb the adresses belongs to "hacker groups" in Russia, China and USA.
@thaddy
I'm not looking for someone to blame. Thanks for information.
Private examples are running over weeks without errors on private networks.
I think the ip4scanner/hackers doing something with server, so the server doesn't responds more.

Soner

  • Sr. Member
  • ****
  • Posts: 318
Re: TFPHTTPServer doesn't respond next day.
« Reply #11 on: September 02, 2020, 11:15:51 am »
I think maybe I have found the solution to the problem.
Some computers are permanently connected to the server, and the server cannot answer new connection request.
I try to increase Server.Queue Size and block computers that send too many requests in last minutes.

Soner

  • Sr. Member
  • ****
  • Posts: 318
I think TFPHTTPServer has a bug on Windows.
« Reply #12 on: October 23, 2020, 10:22:21 am »
Hello,
i wrote a small httpserver-app. It runs on public ip4-adress. I don't published the ipadress, only I and ip4-scanner surfing on my server.
The Server app freezing after one or two days. All my test apps based on TFPHTTPServer like pure TFPHTTPServer or THTTPApplication which based on TFPHTTPServer freezes.
But test server based on Indy or Lhttp running without error.

Does anyone have a TFPHTTPServer-App running on Windows without error?

My Specs:
Windows 10 pro 64Bit, Lazarus 2.0.11 Svn-Rev.63689, Fpc 3.0.4 Win 64.

I upload my test-server projects, if someone want try it.

Edit:
Look at my other topic:
https://forum.lazarus.freepascal.org/index.php/topic,51178.0.html

reinhardt1053

  • New Member
  • *
  • Posts: 14
    • encompass
Re: TFPHTTPServer doesn't respond next day.
« Reply #13 on: September 02, 2024, 06:03:10 pm »
I got the same issue with FPC 3.2.2 and Lazarus 2.2.6. Here a basic example:

Code: Pascal  [Select][+][-]
  1. program httpproject1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   fphttpapp, httpdefs, httproute;
  7.  
  8. procedure route1(aReq: TRequest; aResp: TResponse);
  9. begin
  10.  aResp.content:='<html><body><h1>Route 1 The Default</h1></body></html>'
  11. end;
  12.  
  13.  
  14. begin
  15.  HTTPRouter.registerRoute('/', @route1, true);
  16.  Application.port := 8099;
  17.  Application.threaded := true;
  18.  Application.initialize;
  19.  
  20.  Writeln('Server is running...');
  21.  Application.run;
  22. end.

Run the program and open several browser tab pointing to http://localhost:8099 and run some curl http://localhost:8099. After a while the requests hangs and eventually the browser get a empty response. I wasn't able to understand the origin of the issue, anyone could please point me to the right direction?

There seems to be a bug open here https://gitlab.com/freepascal.org/fpc/source/-/issues/38374

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
Re: TFPHTTPServer doesn't respond next day.
« Reply #14 on: September 02, 2024, 06:18:57 pm »
The bug is not open, the bug is fixed in trunk and possibly also in fixes.
But I am sure they don't want the Trumps back...

 

TinyPortal © 2005-2018