upstream split a header line in FastCGI records

Igor Sysoev is at
Tue Aug 4 14:55:54 MSD 2009

On Tue, Aug 04, 2009 at 01:30:30PM +0400, Igor Sysoev wrote:

> On Mon, Aug 03, 2009 at 03:31:37PM -0400, matrix wrote:
> > For the past 10 hours I have been trying to find out why my application sometimes generates a "502 Bad Gateway" error and sometimes do not, even though the page output should be nearly identical. The error is described by nginx as "upstream prematurely closed connection while reading response header from upstream" without debug and as "upstream split a header line in FastCGI records" with debug.
> > 
> > This only happens when I'm using FirePHP, a debugging class for PHP, which sends information to browser using headers. It would appear that it only happens when the amount of output from FirePHP reaches a certain value that the error happens, as I don't get any errors if FirePHP outputs only a small amount of debug information.
> > 
> > The error still happens if I create a new PHP script with just FirePHP loaded and use it to output a lot of random strings (preset in script). Yet, the error still only happens sometimes (about 50% chance).
> > 
> > I have tried the latest versions of all 3 branches of nginx (legacy, stable and development) with the same results. PHP is 5.3.0, with php-fpm (spawn-fcgi causes same error) and unix sockets as the link between PHP and nginx (TCP connection causes same error).
> > 
> > My fastcgi settings in nginx are:
> > 
> > fastcgi_connect_timeout 60;
> > fastcgi_send_timeout 180;
> > fastcgi_read_timeout 180;
> > fastcgi_buffer_size 128k;
> > fastcgi_buffers 4 256k;
> > fastcgi_busy_buffers_size 256k;
> > fastcgi_temp_file_write_size 256k;
> > fastcgi_intercept_errors on
> > 
> > I've ran nginx in debug mode and got logs of a good page and of a bad page:
> > Good:
> > Bad: (things go bad at line 250)
> > 
> > I hereby request help. Is it a nginx problem or is it something else?
> Try the attached patch.

If it will help, it would be nice if you will create a debug log with
the message "upstream split a header line in FastCGI records" to ensure
that the patch works as I expect.

Igor Sysoev

More information about the nginx mailing list