Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Perl FCGI Error: mod_fcgid: error reading data from FastCGI server

by knox (Sexton)
on Jan 27, 2020 at 20:40 UTC ( [id://11111940]=perlquestion: print w/replies, xml ) Need Help??

knox has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Your wisdom once again is appreciated. I've been testing some FCGI scripts, I've managed to get CGI::Fast working, but I'd like to get FCGI working. Unfortunately, I haven't be able to find good working examples. I'd like to see an example of FCGI return $ENV vars, similar to the CGI::Fast used in the Apache example: https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html. The code posted below is just me trying to get something to work, it is giving an internal server error. I've posted this is from my error log:

[Mon Jan 27 19:44:02.915926 2020] [fcgid:warn] [pid 20681] (104)Connec +tion reset by peer: [client xx.xxx.xxx.xxx:xxxxx] mod_fcgid: error re +ading data from FastCGI server [Mon Jan 27 19:44:02.915973 2020] [core:error] [pid 20681] [client xx. +xxx.xxx.xxx:xxxxx] End of script output before headers: test.fcgi <code> <code> #!/usr/bin/perl use FCGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use Encode; #use CGI::Fast; #the CGI:Fast example from https://httpd.apache.org/mod_fcgid/mod/mod_ +fcgid.html is working; my FCGI example is not. my $count = 0; my $request = FCGI::Request(); while($request->Accept() >= 0) { $body = "Content-type:text/html; charset=utf-8\r\n\r\n"; $body .= '<html><head><meta http-equiv="Content-Type" content="te +xt/html; charset=utf-8" /></head><body>'; $body .= '<h1>Woohoooo!</h1>': $body .= '</body></html>'; $body .= '</body></html>'; $body = encode_utf8($body); print $body; }

Aside from that, I have a very basic question with FastCGI - as it keeps a persistent connection, whats the best way to temporarily test it? I am new to FastCGI, it is compelling, but I don't know the vernacular to describe it well (yet). Let me know if the above doesn't make sense. Secondly, is there a way to get more descriptive error messages than the ones that come out of apache.log?

And yes! I will look into frameworks like Plack/Dancer - but before I do, I'd like to get grasp of how FCGI works before I put a layer on top of it.

Replies are listed 'Best First'.
Re: Perl FCGI Error: mod_fcgid: error reading data from FastCGI server
by hippo (Bishop) on Jan 28, 2020 at 12:15 UTC
    The code posted below is just me trying to get something to work, it is giving an internal server error.

    That's because it doesn't compile:

    $ perl -cw 11111940.pl Status: 500 Content-type: text/html <h1>Software error:</h1> <pre>syntax error at 11111940.pl line 16, near &quot;'&lt;h1&gt;Woohoo +oo!&lt;/h1&gt;':&quot; 11111940.pl had compilation errors. </pre> <p> For help, please send mail to this site's webmaster, giving this error + message and the time and date of the error. </p> [Tue Jan 28 12:12:01 2020] 11111940.pl: syntax error at 11111940.pl li +ne 16, near "'<h1>Woohoooo!</h1>':" [Tue Jan 28 12:12:01 2020] 11111940.pl: 11111940.pl had compilation er +rors.

    If you fix your punctuation you might have better luck.

      thank you.

Re: Perl FCGI Error: mod_fcgid: error reading data from FastCGI server
by Anonymous Monk on Jan 28, 2020 at 10:59 UTC

      Superb, thank you for the answers and all the examples - exactly what I needed to push me along for learning Perl, despite having a typo in my code.

      The socks example was exactly what i meant for testing, without saying succinctly what it was; the code example will be useful for my project.

      To clarify (for me, and for other new learners), CGI::Fast is a "wrapper" for FCGI module. The reason for trying FCGI was following the advice from https://metacpan.org/pod/CGI::Fast "CGI::Fast is based on CGI.pm it is no longer advised as a way to write Perl web apps". I am neutral on other's peoples use of CGI.pm, but as for myself, I want to move away from this module. I will acknowledge that CGI.pm has a great crash course in learning Perl.

      best, knox

Re: Perl FCGI Error: mod_fcgid: error reading data from FastCGI server
by knox (Sexton) on Jan 27, 2020 at 20:44 UTC
    Quick note, this is for Apache24, not nginx

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11111940]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-28 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found