Brook Framework issue and Lazarus 1.6 lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- snorkel · 2016-08-25 19:20 I had to recompile a brook app that has sat for a long time. I installed the brook package and the values var did not work the same. Kept giving me errors unit1.pas(40,31) Error: Incompatible type for arg no. 1: Got "Constant String", expected "LongInt" when the original code was: coid:=Values.['coid'].asstring; had to change it to: coid:=Values.values['coid']; when I run the brook cgi from the command line it just hangs and does not work on the web browser where the original compiled cgi was from a couple of years ago. Is there a different version I should be using for FPC 3.0 and Laz 1.6? I Just downloaded the latest release from the brook site. When I orginally compiled this brook cgi, you could call it from command line and it would out put some text, but now on FPC 3.0 and Laz 1.6 this test just hangs. Anyone have any suggestions on how to get my old brook code working? ---------------------------------------------------------------------- Leledumbo · 2016-08-26 02:07 Brook 3 introduced some backward incompatible changes a while ago, not really remember which version / commit. Some in-house data structures are reverted to use what's available in FPC. Executing CGI on command line shouldn't hang, at least in should only raise exceptions. CGI programs are pure console programs. It must be something else you must debug. ---------------------------------------------------------------------- snorkel · 2016-08-26 17:09 Yep, the original version I did a couple years ago would out put some text from the command line when I would run them like: ./cgi_test I also tried the simple demos with brook 3 and they also hung when run from the command line. I am running the 64bit version of Lazarus and FPC on Kubuntu, not sure if that would matter. ---------------------------------------------------------------------- Leledumbo · 2016-08-26 18:03 I'm on the same x86_64-linux system (but not Kubuntu) and the CGI works perfectly: Code: [Select]$ cat coba.pas {$mode objfpc} uses BrookFCLCGIBroker,BrookApplication,BrookAction; type THelloAction = class(TBrookAction) procedure Get; override; end; procedure THelloAction.Get; begin Write('Hello, World!'); end; begin THelloAction.Register('*'); BrookApp.Run; end. $ ./coba X-Powered-By: Brook framework and FCL-Web. Status: 500 Internal Server Error Content-Length: 177 Content-Type: text/html; charset=utf-8
No REQUEST_METHOD passed from server.
$ REQUEST_METHOD=GET ./coba X-Powered-By: Brook framework and FCL-Web. Status: 200 OK Content-Length: 14 Content-Type: text/html; charset=utf-8 Hello, World! ---------------------------------------------------------------------- snorkel · 2016-08-26 18:18 Your example hangs on my system as well.....grrrrr. Not sure what the heck is going on. ---------------------------------------------------------------------- snorkel · 2016-08-26 18:37 I am going to try and compile the app on my windows system and see if I get the same results. ---------------------------------------------------------------------- snorkel · 2016-08-26 19:01 same exact behavior on windows 32 bit with the release version of brook. Just hangs on BrookApp.Run; All the cgi demo apps hang as well as the example you posted. ---------------------------------------------------------------------- snorkel · 2016-08-26 19:52 well, I take that back about it being the same on windows. On windows it hangs when I run it from the command line, but if I hit CTRL+C I then get some output back. ---------------------------------------------------------------------- snorkel · 2016-08-26 20:28 ok, in case anyone wants to know I got it working. For whatever reason I need to add cthreads to the uses in the project source. only way I found out was by using the Apache web server long to see the error that was logged and it mentioned something about a missing thread library. Anyways works now and I am using the git master version. ---------------------------------------------------------------------- Leledumbo · 2016-08-27 05:06 OK, that's interestingly weird. There should be no requirement for that unless you use embedded HTTP server and set its Threaded property to true. Even if you forget to do so you should still get: Code: [Select]$ cat coba.pas {$mode objfpc} uses BrookFCLHTTPAppBroker,BrookUtils,BrookApplication,BrookAction; type THelloAction = class(TBrookAction) procedure Get; override; end; procedure THelloAction.Get; begin Write('Hello, World!'); end; begin THelloAction.Register('*'); BrookSettings.Port := 2345; (BrookApp.Instance as TBrookHTTPApplication).Threaded := true; BrookApp.Run; end. $ ./coba Open the 'http://localhost:2345' URL in your browser. Use [Ctrl+C] to quit ... This binary has no thread support compiled in. Recompile the application with a thread-driver in the program uses clause before other units using thread. Runtime error 232 at $00000000004192BD $00000000004192BD $00000000004469C6 $00000000004006C8 $00000000004004DD Let's just assume every system is unique (though that doesn't sound logically correct).