2

I have a simple FastCGI script:

public static void main (String args[]) {
        int count = 0;
        while(new FCGIInterface().FCGIaccept()>= 0) {
            count ++;
            System.out.println("Content-type: text/html\n\n");
            System.out.println("<html>");
            System.out.println(
                    "<head><TITLE>FastCGI-Hello Java stdio</TITLE></head>");
            System.out.println("<body>");
            System.out.println("<H3>FastCGI Hello Java stdio</H3>");
            System.out.println("request number " + count +
                    " running on host "
                    + System.getProperty("SERVER_NAME"));
            System.out.println("</body>");
            System.out.println("</html>");
        }
    }

Set up with lighttpd as:

server.modules   += ( "mod_fastcgi" )
fastcgi.debug = 1    
fastcgi.server = ( "/cgi" =>
 ( "fastcgi" =>
   ("port" => 8888,
    "host" => "127.0.0.1",
    "bin-path" => "/var/www/tiny.fcgi",
    "min-procs" => 1,
    "max-procs" => 1,
    "check-local" => "disable" 
 ))
)

In the log:

2012-11-24 04:35:04: (mod_fastcgi.c.1367) --- fastcgi spawning local 
    proc: /var/www/tiny.fcgi 
    port: 54321 
    socket  
    max-procs: 1 
2012-11-24 04:35:04: (mod_fastcgi.c.1391) --- fastcgi spawning 
    port: 54321 
    socket  
    current: 0 / 1 
2012-11-24 04:35:39: (mod_fastcgi.c.3061) got proc: pid: 0 socket: tcp:127.0.0.1:54321 load: 1 

The problem is that there is no data being sent from the server to browser. Am I missing something here?

2 Answers 2

1

I think the Java FastCGI devkit directly from fastcgi.com has some bugs. It was last modified in the year 2000. Check my answer here, the answer has a patch that I needed to apply, for the FastCGI interface to work for more than one request (weird how you don't even get one request through). If the patch doesn't make it work for you on Nginx, the interface probably has more bugs. Consider trying out Apache 2.4+. You could use Wireshark to compare the FastCGI communication and find the other bug, or you could just use Apache 2.4+.

0

Try to use the OutputStream FCGIInterface.request.outStream instead of System.out.

Although the docs claim it would set System.out to point to the FastCGI stream it actually doesn't. Probably no one actually used this ever, might have more bugs :)

1
  • works on my machine (check the link in my answer). They are calling setOut in FCGIInterface, it should work. Feb 24, 2013 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .