Fastcgi problems (connection hangs/time outs)

Hello,

I have a very simple perl fastcgi application (just for testing) and
nginx 0.5.32 and 0.6.13.
With both versions I get nothing in the web browser and the log says
that there is a timeout.

ktrace of the nginx process: (the first read is from the fcgi program,
via localhost/TCP, same with unix socket)
91364 nginx 1191924703.034159 CALL
recvfrom(0xa,0x80fa000,0x1000,0,0,0)
91364 nginx 1191924703.034195 GIO fd 10 read 85 bytes
0x0000 0106 0001 0035 0000 436f 6e74 656e 742d
|…5…Content-|
0x0010 7479 7065 3a20 7465 7874 2f68 746d 6c0d |type:
text/html.|
0x0020 0a43 6f6e 7465 6e74 2d6c 656e 6774 683a
|.Content-length:|
0x0030 2035 0d0a 0d0a 6865 6c6c 6f0d 0a01 0600 |
5…hello…|
0x0040 0100 0000 0001 0300 0100 0800 0000 0000
|…|
0x0050 0000 0000 00 |…|

91364 nginx 1191924703.034199 RET recvfrom 85/0x55
91364 nginx 1191924703.034229 CALL
kevent(0x9,0x80b4000,0,0x80c4000,0x200,0xbfbfea60)
91364 nginx 1191924763.022580 RET kevent 0
91364 nginx 1191924763.022613 CALL gettimeofday(0xbfbfe9b8,0)
91364 nginx 1191924763.022616 RET gettimeofday 0
91364 nginx 1191924763.022634 CALL
kevent(0x9,0x80b4000,0,0x80c4000,0x200,0xbfbfea60)
91364 nginx 1191924763.032573 RET kevent 0
91364 nginx 1191924763.032583 CALL gettimeofday(0xbfbfe9b8,0)
91364 nginx 1191924763.032585 RET gettimeofday 0
91364 nginx 1191924763.032613 CALL write(0x4,0xbfbfe1e0,0xe6)
91364 nginx 1191924763.032635 GIO fd 4 wrote 230 bytes
"2007/10/09 12:12:43 [error] 91364#0: *1 upstream timed out (60:
Operat
ion timed out) while reading upstream, client: 172.16.129.150,
server:
localhost, URL: “/”, upstream: “fastcgi://127.0.0.1:1026”,
host: “jap
an.asdfghj.private”
"
91364 nginx 1191924763.032639 RET write 230/0xe6
91364 nginx 1191924763.033010 CALL close(0xa)
91364 nginx 1191924763.033588 RET close 0

I’ve also tried the same program with lighttpd and there everything
works fine:

90925 lighttpd GIO fd 8 read 85 bytes
0x0000 0106 0001 0035 0000 436f 6e74 656e 742d
|…5…Content-|
0x0010 7479 7065 3a20 7465 7874 2f68 746d 6c0d |type:
text/html.|
0x0020 0a43 6f6e 7465 6e74 2d6c 656e 6774 683a
|.Content-length:|
0x0030 2035 0d0a 0d0a 6865 6c6c 6f0d 0a01 0600 |
5…hello…|
0x0040 0100 0000 0001 0300 0100 0800 0000 0000
|…|
0x0050 0000 0000 00 |…|

90925 lighttpd RET read 85/0x55
90925 lighttpd CALL kevent(0x6,0xbfbfe930,0x1,0,0,0xbfbfe928)
90925 lighttpd RET kevent 0
90925 lighttpd CALL close(0x8)
90925 lighttpd RET close 0
[…]
the above little page gets served to the browser.

nginx config:
worker_processes 1;
error_log /tmp/nginx.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
include fastcgi_params;
fastcgi_pass 127.0.0.1:1026;
fastcgi_param SCRIPT_FILENAME
/scripts$fastcgi_script_name;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
}

And the program, which serves the fastcgi response:
use FCGI::Async;
use IO::Async::Set::IO_Poll;

my $fcgi = FCGI::Async->new(
port => 1026,
on_request => sub {
my ($fcgi, $req) = @_;
my $page = “hello”;
$req->print_stdout(
“Content-type: text/html\r\n”.
“Content-length: “.length($page).”\r\n”.
“\r\n”.
$page."\r\n"
);
$req->finish();
}
);

my $set = IO::Async::Set::IO_Poll->new();

$set->add($fcgi);
$set->loop_forever;

(but I’ve tried with a completely different stuff,
POE::Component::FastCGI and the effect is the same)

Any ideas?

ps: please keep me on CC.

Thanks,

Hello,

As always, I’ve forgot to tell that this is on FreeBSD 6-STABLE/i386.

I’ve also tried select instead of kqueue, but nothing happened:
96817 nginx 1191926437.380087 CALL
recvfrom(0x9,0x80bc000,0x1000,0,0,0)
96817 nginx 1191926437.380129 GIO fd 9 read 80 bytes
0x0000 0106 0001 002e 0200 5374 6174 7573 3a20 |…Status:
|
0x0010 3230 300d 0a43 6f6e 7465 6e74 2d54 7970
|200…Content-Typ|
0x0020 653a 2074 6578 742f 6874 6d6c 0d0a 0d0a |e:
text/html…|
0x0030 7661 6c61 6d69 0000 0106 0001 0000 0000
|valami…|
0x0040 0103 0001 0008 0000 0000 0000 0000 0000
|…|
96817 nginx 1191926437.380134 RET recvfrom 80/0x50
96817 nginx 1191926437.380166 CALL
select(0xa,0x8098a60,0x8098ae0,0,0xbfbfe
a60)
96817 nginx 1191926497.364856 RET select 0
96817 nginx 1191926497.364886 CALL gettimeofday(0xbfbfe9b8,0)
96817 nginx 1191926497.364889 RET gettimeofday 0
96817 nginx 1191926497.364929 CALL write(0x4,0xbfbfe1e0,0xe6)
96817 nginx 1191926497.364951 GIO fd 4 wrote 230 bytes
"2007/10/09 12:41:37 [error] 96817#0: *1 upstream timed out (60:
Operat
ion timed out) while reading upstream, client: 172.16.129.150,
server:
localhost, URL: “/”, upstream: “fastcgi://127.0.0.1:1026”,
host: “jap
an.asdfghj.private”
"
96817 nginx 1191926497.364955 RET write 230/0xe6
96817 nginx 1191926497.365330 CALL close(0x9)
96817 nginx 1191926497.366573 RET close 0

On 10/09/07 12:23, Attila Nagy wrote:

recvfrom(0xa,0x80fa000,0x1000,0,0,0)
kevent(0x9,0x80b4000,0,0x80c4000,0x200,0xbfbfea60)
"2007/10/09 12:12:43 [error] 91364#0: *1 upstream timed out (60:

error_log /tmp/nginx.log debug;
server_name localhost;
}
my $page = “hello”;
my $set = IO::Async::Set::IO_Poll->new();

$set->add($fcgi);
$set->loop_forever;

(but I’ve tried with a completely different stuff,
POE::Component::FastCGI and the effect is the same)

Any ideas?
I saw some e-mails in the archive regarding fastcgi, but not neither of
them was about it does not work in nginx.
Could it be that it’s OS specific, or is it just me? The above is on
FreeBSD/i386.

Thanks,