Recent

Author Topic: FCGI + IIS issue  (Read 404 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1119
FCGI + IIS issue
« on: February 05, 2023, 09:49:39 am »
Hope that those interested in web programming remember I have posted several threads regarding FCGI's rasing exceptions under IIS. Now there seems to be a possibility that this is caused by TDataModule or TWebmodule. Now I have made a fcgi application not using webmodule nor datamodule. Following is the codes.

Code: Pascal  [Select][+][-]
  1. unit ufcgi2;
  2.  
  3. {$mode ObjFPC}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.    Classes, SysUtils,  httpdefs, fpHTTP, fpWeb, httproute,
  9.    IBConnection, SQLDB;
  10.  
  11. var
  12.    IBConnection1: TIBConnection;
  13.    SQLQuery1: TSQLQuery;
  14.    SQLTransaction1: TSQLTransaction;
  15.  
  16.    function TestContent: string;
  17.    procedure Hello (ARequest:TRequest; AResponse: TResponse);
  18.  
  19. implementation
  20.  
  21. uses DB;
  22.  
  23. var
  24.    cnt : integer = 0;
  25.  
  26. function TestContent: string;
  27. var
  28.    Field: TField;
  29. begin
  30.    with SQLQuery1 do begin
  31.       SQL.text := 'Select * from TEST';
  32.       Transaction.Active := True;
  33.       Open;
  34.  
  35.       Result := '<table>';
  36.       First;
  37.       while not eof do begin
  38.          Result += '<tr>';
  39.          for Field in Fields do begin
  40.             Result += Format('<td>%s</td>', [Field.AsString]) ;
  41.          end;
  42.          Result += '</tr>';
  43.          Next;
  44.       end;
  45.       Result += '</table>';
  46.       (Transaction as TSQLTransaction).Rollback;
  47.    end;
  48. end;
  49.  
  50.  
  51. procedure Hello(ARequest: TRequest; AResponse: TResponse);
  52. begin
  53.    cnt += 1;
  54.    AResponse.Content := 'Count: ' + IntToStr(cnt) + '<br>';
  55.    AResponse.Content := AResponse.Content + TestContent;
  56. end;
  57.  
  58. initialization
  59.     ibconnection1 := TIBConnection.Create(nil);
  60.     with ibconnection1 do begin
  61.        DatabaseName:= 'd:\DBS\aq03.fdb';
  62.        Username := 'sysdba';
  63.        Password := 'masterkey';
  64.        Connected := True;
  65.     end;
  66.     sqltransaction1 := TSQLTransaction.Create(nil);
  67.     SQLTransaction1.DataBase := ibconnection1;
  68.  
  69.     sqlquery1 := TSQLQuery.Create(nil);
  70.     sqlquery1.DataBase := ibconnection1;
  71.  
  72.     HTTPRouter.RegisterRoute('*', @Hello);
  73. finalization
  74.    ibconnection1.connected := False;
  75.    SQLQuery1.Free;
  76.    SQLTransaction1.Free;
  77.    ibconnection1.Free;
  78.  
  79. end.
  80.  

Originally DB-related components were in a separate DataModule. With TDataModule, it causes errors after about 15~20 requests (by pressing F5).

But with the new approach listed above, I cannot cause the error how fast I press F5  :D

Hope the developers may give some insights if possible.

egsuh

  • Hero Member
  • *****
  • Posts: 1119
Re: FCGI + IIS issue
« Reply #1 on: February 05, 2023, 09:52:49 am »
Sorry. Still error happens, but rather infrequently. About after processing 50 requests.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8595
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: FCGI + IIS issue
« Reply #2 on: February 13, 2023, 03:22:36 am »
Compile -gl and see the stacktrace when the exception occurs.

 

TinyPortal © 2005-2018