silvioprog / brookframework

Microframework which helps to develop web Pascal applications.
https://github.com/risoflora/brookframework
GNU Lesser General Public License v3.0
170 stars 37 forks source link

Some issues in the wizard generated project (Lazarus) #1

Closed leledumbo closed 11 years ago

leledumbo commented 11 years ago

Exception at 080AAAFA: Exception: Failed to open input-handle passed from server. Socket Error: 88.

Lazarus 1.1 r38762 FPC 2.7.1 rXXXX (about 1 month old)

silvioprog commented 11 years ago

Fixed (https://github.com/silvioprog/brookframework/commit/45df610ae8fc86dec9353665ec981429c176fac0). Please test it. Thank you! :)

leledumbo commented 11 years ago

Sorry for the late reply, just remembered about this issue. The charset problem is fixed, but action already exists and binary execution problem is still there. The problem is still exactly as above. Moreover, by default, the project is not runnable even though I choose FastCGI. Is this intended?

leledumbo commented 11 years ago

Closed by mistake

silvioprog commented 11 years ago

No problem friend. These days I was away partying the Christmas. :) Finally, the problem in action editor is solved (https://github.com/silvioprog/brookframework/commit/e3f5567c74817d7ffe69db7c485d1d9307412af7). Now, I'm using the "Index" instead "Data" property. About the "error 88", what's your environment (Linux, Windows, Apache ...)? I'm using Apache (32/64bit) on Linux and Windows, and it works fine with CGI and/or FastCGI. The intended is to disable the "Run" button. You could to run a CGI inside the IDE? I've never tried it, because the CGI/FCGI depend of environment variables to work.

leledumbo commented 11 years ago

OK, I'll pull again. About error 88, I'm using Nginx on 32-bit Linux. Nginx doesn't manage the FastCGI binary by itself and we have to start the binary ourselves. Moreover, I'll need to run from IDE in order to debug. That's what I did with my fpweb projects.

silvioprog commented 11 years ago

If the error in the action editor occurs again, we will solve it. I have the Linux Mint (64bit), I'll try to install Nginx to reproduce the problem with error 88. So, by default, fpWeb keeps the Run button enabled? If yes, I may change the brookex to maintain compatibility with fpWeb.

leledumbo commented 11 years ago

Yes, even it's enabled for CGI, though it's relevant only in FastCGI.

silvioprog commented 11 years ago

Hm... so it would be interesting to let enabled for CGI and FastCGI?

silvioprog commented 11 years ago

[I'm downloading the Nginx for Windows to reproduce the error 88: http://nginx.org/en/docs/windows.html]

leledumbo commented 11 years ago

I'd say let it enabled for FastCGI only. You don't need to download any webserver, since the error happens immediately after starting the binary.

silvioprog commented 11 years ago

Now the Run button is enabled for FastCGI applications (https://github.com/silvioprog/brookframework/commit/a8e0cfc711c2b122a0efc2d186c9aac1580620ab). Thank you!

Yes, after starting the binary, I got:

C:\Users\silvioprog\Desktop\fcgi>cgi1.exe
Exception at 00434BAC: Exception:
Failed to open input-handle passed from server. Socket Error: 6.

But...

For FastCGI applications, maybe you must be specify the port. Please test this demo, I specified a port (2015) to it:

http://www.sendspace.com/file/mwm0ct

In two pictures below, see FastCGI working:

1 - http://imagebin.org/240843 2 - http://imagebin.org/240844

I think that it will work now for you. :)

leledumbo commented 11 years ago

YES!!! IT WORKS!!! I'll keep exploring the framework, it's damn big. Now that you know FastCGI requires Port to be set, would you modify the generated project? IMO, it's better to put the Port initialization in the .lpr, but if you want to put it in Brokers (I don't really know what's this unit's job actually, request broker?), that's fine.

silvioprog commented 11 years ago

Nice job guy! :+1:

The Port is necessary when you use FastCGI manually (starting the executable via terminal). Using automatically (for example, in Apache) the Port used is the default.

In Brokers unit you configure any part of your application. The idea is exactly have a central point for you find everything related to initializations and settings. :) E.g (pseudo example):

unit Brokers;

{$mode objfpc}{$H+}

interface

uses
  BrookApplication, BrookFCLCGIBroker, BrookSQLdbBroker, SQLite3Conn,
  BrookUtils, Classes, SysUtils;

implementation

var
  App: TBrookCGIApplication;
  EnvVars: TStringList;

initialization
  EnvVars := TStringList.Create;
  App := TBrookCGIApplication(BrookApp.Instance);
  App.GetCGIVarList(EnvVars);
  App.Email := 'webmaster@localhost';
  App.ApplicationURL := 'http://localhost';
  App.RedirectOnError := True;
  App.RedirectOnErrorURL := 'http://localhost/500.html';
  BrookSettings.Configuration := 'db.cfg';
  BrookSettings.Page404 :=
    '<html><head><title>Page not found</title></head><body>' +
    '<h1>404 - Page not found</h1></body></html>';

finalization
  FreeAndNil(EnvVars);

end.