# FastCGI backend issue

**URL:** <https://www.ruby-forum.com/t/fastcgi-backend-issue/202252>\
**Category:** NGINX\
**Created:** [January 25, 2011, 10:39am UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252 "2011-01-25T10:39:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 25, 2011, 10:39am UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/1 "2011-01-25T10:39:58Z")

</div>

I’ve got a self-written FastCGI backend. It works with Lighttpd, but not  
with Nginx. Nginx connects to the backend, sends the request, receives  
the response, but then appears to wait on something else.

The backend writes one or more FCGI\_STDOUT packets and a  
FCGI\_END\_REQUEST packet. Any hints on what’s wrong?

writev(10,  
[{“\1\1\0\1\0\10\0\0\0\1\0\0\0\0\0\0\1\4\0\1\3\212\6\0\f\0QUERY\_”…,  
952}], 1) = 952  
epoll\_wait(8, {{EPOLLIN|EPOLLOUT, {u32=3285521105,  
u64=139778701202129}}}, 512, 59998) = 1  
recvfrom(10, “\1\6\0\1\2[\0\0Content-Type: text/html;”…, 4096, 0,  
NULL, NULL) = 635  
readv(10, 0x7fff5452b860, 1) = -1 EAGAIN (Resource temporarily  
unavailable)  
epoll\_wait(8, {}, 512, 59962) = 0

Posted at Nginx Forum:

> **[FastCGI backend issue](https://forum.nginx.org/read.php?2,169360,169360#msg-169360)**
>
> I've got a self-written FastCGI backend. It works with Lighttpd, but not with Nginx. Nginx connects to the backend, sends the request, receives the response, but then appears to wait on something else. The backend writes one or more FCGI\_STDOUT...

---

<div class="post-metadata">

**Author:** ![Olaf\_van\_der\_Spek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Olaf\_van\_der\_Spek](https://www.ruby-forum.com/u/Olaf_van_der_Spek)\
**Post date:** [January 25, 2011, 11:51am UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/2 "2011-01-25T11:51:07Z")

</div>

Hello!

On Tue, Jan 25, 2011 at 04:38:31AM -0500, Olaf van der Spek wrote:

> I’ve got a self-written FastCGI backend. It works with Lighttpd, but not  
> with Nginx. Nginx connects to the backend, sends the request, receives  
> the response, but then appears to wait on something else.
> 
> The backend writes one or more FCGI\_STDOUT packets and a  
> FCGI\_END\_REQUEST packet. Any hints on what’s wrong?

Most likely your backend doesn’t honor FCGI\_KEEP\_CONN flag.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Olaf\_van\_der\_Spek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Olaf\_van\_der\_Spek](https://www.ruby-forum.com/u/Olaf_van_der_Spek)\
**Post date:** [January 25, 2011, 1:53pm UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/3 "2011-01-25T13:53:37Z")

</div>

Maxim D. Wrote:

> Most likely your backend doesn’t honor  
> FCGI\_KEEP\_CONN flag.

It doesn’t. Why does Nginx wait after FCGI\_END\_REQUEST though?

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,169360,169402#msg-169402](http://forum.nginx.org/read.php?2,169360,169402#msg-169402)

---

<div class="post-metadata">

**Author:** ![Olaf\_van\_der\_Spek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Olaf\_van\_der\_Spek](https://www.ruby-forum.com/u/Olaf_van_der_Spek)\
**Post date:** [January 25, 2011, 2:21pm UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/4 "2011-01-25T14:21:54Z")

</div>

Hello!

On Tue, Jan 25, 2011 at 07:52:18AM -0500, Olaf van der Spek wrote:

> Maxim D. Wrote:
> 
> > Most likely your backend doesn’t honor  
> > FCGI\_KEEP\_CONN flag.
> 
> It doesn’t. Why does Nginx wait after FCGI\_END\_REQUEST though?

nginx doesn’t process data from fastcgi app untill buffer filled or  
connection closed by app (as required per spec without  
FCGI\_KEEP\_CONN flag set).

I’ve posted some patches which change things as part of keepalive  
with backends work, but most likely you don’t want to rely on  
them. You may want to make your app actually fastcgi complaint  
instead.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Olaf\_van\_der\_Spek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Olaf\_van\_der\_Spek](https://www.ruby-forum.com/u/Olaf_van_der_Spek)\
**Post date:** [January 25, 2011, 2:42pm UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/5 "2011-01-25T14:42:39Z")

</div>

> nginx doesn’t process data from fastcgi app untill  
> buffer filled or  
> connection closed by app (as required per spec  
> without  
> FCGI\_KEEP\_CONN flag set).

What part of the spec requires the webserver to wait until the  
connection is closed by the backend?  
Doesn’t Nginx support (and use) persistent connections?

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,169360,169414#msg-169414](http://forum.nginx.org/read.php?2,169360,169414#msg-169414)

---

<div class="post-metadata">

**Author:** ![Olaf\_van\_der\_Spek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Olaf\_van\_der\_Spek](https://www.ruby-forum.com/u/Olaf_van_der_Spek)\
**Post date:** [January 25, 2011, 4:51pm UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/6 "2011-01-25T16:51:29Z")

</div>

Hello!

On Tue, Jan 25, 2011 at 08:41:29AM -0500, Olaf van der Spek wrote:

> > nginx doesn’t process data from fastcgi app untill  
> > buffer filled or  
> > connection closed by app (as required per spec  
> > without  
> > FCGI\_KEEP\_CONN flag set).
> 
> What part of the spec requires the webserver to wait until the  
> connection is closed by the backend?

Spec requires app to close connection if no FCGI\_KEEP\_CONN flag  
set.

> Doesn’t Nginx support (and use) persistent connections?

No.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Olaf\_van\_der\_Spek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Olaf\_van\_der\_Spek](https://www.ruby-forum.com/u/Olaf_van_der_Spek)\
**Post date:** [February 4, 2011, 7:58pm UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/7 "2011-02-04T19:58:15Z")

</div>

Somebody?

Posted at Nginx Forum:

> **[Re: FastCGI backend issue](https://forum.nginx.org/read.php?2,169360,172224#msg-172224)**
>
> I've got a self-written FastCGI backend. It works with Lighttpd, but not with Nginx. Nginx connects to the backend, sends the request, receives the response, but then appears to wait on something else. The backend writes one or more FCGI\_STDOUT...

---

<div class="post-metadata">

**Author:** ![Olaf\_van\_der\_Spek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f0a364/32.png) [@Olaf\_van\_der\_Spek](https://www.ruby-forum.com/u/Olaf_van_der_Spek)\
**Post date:** [January 27, 2011, 6:26pm UTC](https://www.ruby-forum.com/t/fastcgi-backend-issue/202252/8 "2011-01-27T18:26:06Z")

</div>

> I’ve posted some patches which change things as  
> part of keepalive  
> with backends work, but most likely you don’t want  
> to rely on  
> them. You may want to make your app actually

Is there an bug/issue tracker that tracks this?

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,169360,170181#msg-170181](http://forum.nginx.org/read.php?2,169360,170181#msg-170181)
