caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Netcgi_fcgi
@ 2009-07-16 11:27 Anders Thøgersen
       [not found] ` <BB046CA812535C45BD0029AA9D04BA7906676353@KL-SRV57.lmsintl.com>
  2009-07-16 14:27 ` Christophe TROESTLER
  0 siblings, 2 replies; 8+ messages in thread
From: Anders Thøgersen @ 2009-07-16 11:27 UTC (permalink / raw)
  To: caml-list

Hello,

I am trying to get the fastcgi examples from netcgi2 to work, but am
having some problems with this.  I am running with apache2 and
mod_fcgid.

I have compiled the counter_fcgi example with ocamlopt and copied the
executable to my fcgid directory.  When pointing my browser at the url
of the binary I get an internal server error and the logs contain the
following:

    [Thu Jul 16 13:20:38 2009] [warn] (104)Connection reset by peer:  mod_fcgid: read data from fastcgi server error.
    [Thu Jul 16 13:20:38 2009] [error] [client 127.0.1.1] Premature end of script headers: counter.fcgi

I can see that a socket is created for communication between apache and
counter.fcgi, so something is functioning correctly, and I am unsure
what the problem might be.

Any pointers are welcome!

Regards
Anders


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Netcgi_fcgi
       [not found] ` <BB046CA812535C45BD0029AA9D04BA7906676353@KL-SRV57.lmsintl.com>
@ 2009-07-16 13:31   ` Anders Thøgersen
  0 siblings, 0 replies; 8+ messages in thread
From: Anders Thøgersen @ 2009-07-16 13:31 UTC (permalink / raw)
  To: Christoph Bauer; +Cc: caml-list

Hi,

On 14:58 Thu 16 Jul 2009, Christoph Bauer wrote:
> Hi,
> 
> I don't know the netcgi stuff, but from the message I guess, that
> your HTTP-Header of your script is wrong. Make sure, that
> the first lines of your program are a valid HTTP header, and that
> each line is terminated with \r\n. Before your HTML, there
> should be an empty line (i.e. \r\n\r\n).

I do not think this is the case since these are the example programs
that come with the distribution and so should work out of the box.

I have tried the counter_fcgi and add_fcgi examples under mod_fcgid and
mod_fastcgi with apache2, but I can not get the examples to work.

Under mod_fastcgi I get a slightly different error message:

    [Thu Jul 16 15:05:09 2009] [error] [client 127.0.1.1] FastCGI: comm with server "/home/alt/projects/ocaml/www/counter.fcgi" aborted: idle timeout (30 sec)
    [Thu Jul 16 15:05:09 2009] [error] [client 127.0.1.1] FastCGI: incomplete headers (0 bytes) received from server "/home/alt/projects/ocaml/www/counter.fcgi"

Which suggests that apache and counter.fcgi can see each other, but that the 
communication between the two is somehow not functioning.  

I should mention that I am using the netcgi2 lib from godi-ocamlnet.

Previously I used debians standard ocaml packages, but I am now using
godi exclusively.  Maybe I have somehow linked with something from my
old ocaml installation and in this way messed something up?

I'll keep trying for a while,...

Regards
Anders

> Christoph Bauer
> 
> > -----Original Message-----
> > From: caml-list-bounces@yquem.inria.fr 
> > [mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Anders 
> > Thøgersen
> > Sent: Thursday, July 16, 2009 1:28 PM
> > To: caml-list@yquem.inria.fr
> > Subject: [Caml-list] Netcgi_fcgi
> > 
> > Hello,
> > 
> > I am trying to get the fastcgi examples from netcgi2 to work, 
> > but am having some problems with this.  I am running with 
> > apache2 and mod_fcgid.
> > 
> > I have compiled the counter_fcgi example with ocamlopt and 
> > copied the executable to my fcgid directory.  When pointing 
> > my browser at the url of the binary I get an internal server 
> > error and the logs contain the
> > following:
> > 
> >     [Thu Jul 16 13:20:38 2009] [warn] (104)Connection reset 
> > by peer:  mod_fcgid: read data from fastcgi server error.
> >     [Thu Jul 16 13:20:38 2009] [error] [client 127.0.1.1] 
> > Premature end of script headers: counter.fcgi
> > 
> > I can see that a socket is created for communication between 
> > apache and counter.fcgi, so something is functioning 
> > correctly, and I am unsure what the problem might be.
> > 
> > Any pointers are welcome!
> > 
> > Regards
> > Anders
> > 
> > _______________________________________________
> > Caml-list mailing list. Subscription management:
> > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> > Archives: http://caml.inria.fr
> > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> > Bug reports: http://caml.inria.fr/bin/caml-bugs
> > 
> 
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Netcgi_fcgi
  2009-07-16 11:27 Netcgi_fcgi Anders Thøgersen
       [not found] ` <BB046CA812535C45BD0029AA9D04BA7906676353@KL-SRV57.lmsintl.com>
@ 2009-07-16 14:27 ` Christophe TROESTLER
  2009-07-16 15:08   ` Anders Thøgersen
  1 sibling, 1 reply; 8+ messages in thread
From: Christophe TROESTLER @ 2009-07-16 14:27 UTC (permalink / raw)
  To: anders; +Cc: caml-list

On Thu, 16 Jul 2009 13:27:55 +0200, Anders Thøgersen wrote:
> 
> Hello,
> 
> I am trying to get the fastcgi examples from netcgi2 to work, but am
> having some problems with this.  I am running with apache2 and
> mod_fcgid.
> 
> I have compiled the counter_fcgi example with ocamlopt and copied the
> executable to my fcgid directory.

You should be aware that there are several ways for a web server to
contact a FCGI script.  According to what you say, you are expecting
the web server to start (then and contact the script on stdin), in
which case you have to comment out the "sockaddr" argument (see
netcgi_fcgi.mli).  The counter_fcgi.ml example, as it prints on
stdout, expects to be started manually and be contacted by the web
server on port 1200.  Please see the FCGI doc about how to do that.
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html 

If you believe that the examples should tell more about how FCGI
connectors work, feel free to write some comment to put at the
beginning of the files and send it to me.

Best,
C.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Netcgi_fcgi
  2009-07-16 14:27 ` Christophe TROESTLER
@ 2009-07-16 15:08   ` Anders Thøgersen
  2009-07-17 13:12     ` Christophe TROESTLER
  0 siblings, 1 reply; 8+ messages in thread
From: Anders Thøgersen @ 2009-07-16 15:08 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: caml-list

Hello,

On 16:27 Thu 16 Jul 2009, Christophe TROESTLER wrote:
> On Thu, 16 Jul 2009 13:27:55 +0200, Anders Thøgersen wrote:
> > 
> > Hello,
> > 
> > I am trying to get the fastcgi examples from netcgi2 to work, but am
> > having some problems with this.  I am running with apache2 and
> > mod_fcgid.
> > 
> > I have compiled the counter_fcgi example with ocamlopt and copied the
> > executable to my fcgid directory.
> 
> You should be aware that there are several ways for a web server to
> contact a FCGI script.  According to what you say, you are expecting
> the web server to start (then and contact the script on stdin), in
> which case you have to comment out the "sockaddr" argument (see
> netcgi_fcgi.mli).  The counter_fcgi.ml example, as it prints on

I have also tried this, but to no avail. I still get an internal server
error and a message about a timeout in the logs.

> stdout, expects to be started manually and be contacted by the web
> server on port 1200.  Please see the FCGI doc about how to do that.
> http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html 

I believe I have done this part correctly, though. Here's a sample
session when starting the program from the commandline as you suggest:

    $ ./counter.fcgi
    ./counter.fcgi (FCGI) listening on port 1200.

And in another shell:

    $ lynx 127.0.0.1:1200

This waits indefinately.  A timeout is also what is reported by
mod_fastcgi.

Maybe I am missing something very obviuos.  Often that is a reason for
obscure problems like this  :-/

> 
> If you believe that the examples should tell more about how FCGI
> connectors work, feel free to write some comment to put at the
> beginning of the files and send it to me.

Yes, I must admint that my knowledge of the FCGI protocol is limited.  I
will gladly do this once I get to the bottom of this problem.

Regards
Anders

> Best,
> C.
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Netcgi_fcgi
  2009-07-16 15:08   ` Anders Thøgersen
@ 2009-07-17 13:12     ` Christophe TROESTLER
  2009-07-17 14:22       ` Anders Thøgersen
  2009-07-17 14:33       ` Christophe TROESTLER
  0 siblings, 2 replies; 8+ messages in thread
From: Christophe TROESTLER @ 2009-07-17 13:12 UTC (permalink / raw)
  To: anders; +Cc: caml-list

On Thu, 16 Jul 2009 17:08:54 +0200, Anders Thøgersen wrote:
> 
> I believe I have done this part correctly, though. Here's a sample
> session when starting the program from the commandline as you suggest:
> 
>     $ ./counter.fcgi
>     ./counter.fcgi (FCGI) listening on port 1200.
> 
> And in another shell:
> 
>     $ lynx 127.0.0.1:1200
> 
> This waits indefinately.  A timeout is also what is reported by
> mod_fastcgi.

You are supposed to talk the FCGI (binary) protocol on port 1200.
Trying to access it with a browser (HTTP protocol) will do nothing
interesting.  You have to configure your web server so it contact
localhost:1200 when you request the URL you want.  According to
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html it should be
someting like

  FastCgiExternalServer path/to/url -host localhost:1200

Hope it helps,
C.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Netcgi_fcgi
  2009-07-17 13:12     ` Christophe TROESTLER
@ 2009-07-17 14:22       ` Anders Thøgersen
  2009-07-17 14:33       ` Christophe TROESTLER
  1 sibling, 0 replies; 8+ messages in thread
From: Anders Thøgersen @ 2009-07-17 14:22 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: caml-list

Hi,

On 15:12 Fri 17 Jul 2009, Christophe TROESTLER wrote:
> On Thu, 16 Jul 2009 17:08:54 +0200, Anders Thøgersen wrote:
> > 
> > I believe I have done this part correctly, though. Here's a sample
> > session when starting the program from the commandline as you suggest:
> > 
> >     $ ./counter.fcgi
> >     ./counter.fcgi (FCGI) listening on port 1200.
> > 
> > And in another shell:
> > 
> >     $ lynx 127.0.0.1:1200
> > 
> > This waits indefinately.  A timeout is also what is reported by
> > mod_fastcgi.
> 
> You are supposed to talk the FCGI (binary) protocol on port 1200.
> Trying to access it with a browser (HTTP protocol) will do nothing
> interesting.  You have to configure your web server so it contact
> localhost:1200 when you request the URL you want.  According to
> http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html it should be
> someting like
> 
>   FastCgiExternalServer path/to/url -host localhost:1200

Do'h!  sorry for being such a n00b :-/

> Hope it helps,

Yes, indeed I have gotten the examples to work, thanks!

I'll see if I can write a small text to guide new users like myself.

Regards
Anders

> C.
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Netcgi_fcgi
  2009-07-17 13:12     ` Christophe TROESTLER
  2009-07-17 14:22       ` Anders Thøgersen
@ 2009-07-17 14:33       ` Christophe TROESTLER
  2009-07-22 12:57         ` Anders Thøgersen
  1 sibling, 1 reply; 8+ messages in thread
From: Christophe TROESTLER @ 2009-07-17 14:33 UTC (permalink / raw)
  To: anders; +Cc: caml-list

On Fri, 17 Jul 2009 15:12:08 +0200, Christophe TROESTLER wrote:
> 
> On Thu, 16 Jul 2009 17:08:54 +0200, Anders Thøgersen wrote:
> > 
> > I believe I have done this part correctly, though. Here's a sample
> > session when starting the program from the commandline as you suggest:
> > 
> >     $ ./counter.fcgi
> >     ./counter.fcgi (FCGI) listening on port 1200.

Recipe:

1. Add to your apache conf

   FastCgiExternalServer /var/www/fcgi -host localhost:1200

   where /var/www is directory where apache looks for files (see the
   error log for the filename that is sought after point 3. if it
   fails with "Not found").

   Restart Apache.

   REM: the file /var/www/fcgi need not to exist.

2. Launch ./counter.fcgi

3. Point your browser to http://localhost/fcgi

C.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Netcgi_fcgi
  2009-07-17 14:33       ` Christophe TROESTLER
@ 2009-07-22 12:57         ` Anders Thøgersen
  0 siblings, 0 replies; 8+ messages in thread
From: Anders Thøgersen @ 2009-07-22 12:57 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: caml-list

Hi,

On 16:33 Fri 17 Jul 2009, Christophe TROESTLER wrote:
> On Fri, 17 Jul 2009 15:12:08 +0200, Christophe TROESTLER wrote:
> > 
> > On Thu, 16 Jul 2009 17:08:54 +0200, Anders Thøgersen wrote:
> > > 
> > > I believe I have done this part correctly, though. Here's a sample
> > > session when starting the program from the commandline as you suggest:
> > > 
> > >     $ ./counter.fcgi
> > >     ./counter.fcgi (FCGI) listening on port 1200.
> 
> Recipe:
> 
> 1. Add to your apache conf
> 
>    FastCgiExternalServer /var/www/fcgi -host localhost:1200
> 
>    where /var/www is directory where apache looks for files (see the
>    error log for the filename that is sought after point 3. if it
>    fails with "Not found").
> 
>    Restart Apache.
> 
>    REM: the file /var/www/fcgi need not to exist.
> 
> 2. Launch ./counter.fcgi
> 
> 3. Point your browser to http://localhost/fcgi

This describes very nicely the steps!  Thanks.

Anders

> C.
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-07-22 12:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-16 11:27 Netcgi_fcgi Anders Thøgersen
     [not found] ` <BB046CA812535C45BD0029AA9D04BA7906676353@KL-SRV57.lmsintl.com>
2009-07-16 13:31   ` [Caml-list] Netcgi_fcgi Anders Thøgersen
2009-07-16 14:27 ` Christophe TROESTLER
2009-07-16 15:08   ` Anders Thøgersen
2009-07-17 13:12     ` Christophe TROESTLER
2009-07-17 14:22       ` Anders Thøgersen
2009-07-17 14:33       ` Christophe TROESTLER
2009-07-22 12:57         ` Anders Thøgersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).