Welcome! Log In Create A New Profile

Advanced

Dummy question readv() failed 104

Posted by xengine 
Dummy question readv() failed 104
February 19, 2010 02:47PM
Hello,

I'm little lost becouse i have and script that work ok at local on cli php mode and when i upload to production server with nginx and fastcgi it crash.

The PHP log haven't got any report of error using E_ALL and in fact the script works a moment and then suddenly stop.

On Nginx log appear "readv() failed (104: Connection reset by peer) while reading upstream"

Basically i have:

[code]
$obj = new Name;
$some = $obj->do_something(); // at here work ok
//Doing the same
$some = $obj->do_something(); // it crash.
[/code]

I increased the php memory limit, workers on nginx, the timeout fastcgi on nginx, I added more fastcgi process, etc, but nothing happend, always report the same.

I use socket to connect from nginx to fastcgi.

So what's the next step to know what's happend? and How could i know what is happening behind the scenes?
Re: Dummy question readv() failed 104
February 19, 2010 03:24PM
If i run the script on php-cgi mode at console works like a charm!

I'm using nginx version: nginx/0.8.33

and fastcgi script on ubuntu:

[code]
#! /bin/sh
#
### BEGIN INIT INFO
# Provides: php-fastcgi
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop php-cgi in external FASTCGI mode
# Description: Start and stop php-cgi in external FASTCGI mode
### END INIT INFO
#
# Do NOT "set -e"
# Default values are enclosed in []


# Read configuration data
NAME=php-fastcgi
DESC="php-cgi runing in external FASTCGI mode"
PIDFILE=/var/run/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Daemon pathname and args
#BIND=127.0.0.1:9000
BIND="/var/run/nginx/$NAME.sock"
USER=www-data
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=250
export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -q -b $BIND"

# Exit if php-cgi is not installed
[ -x "$PHP_CGI" ] || exit 0

# Load rcS variable settings and set (re)start/stop verbosity
[ -f /etc/default/rcS ] && . /etc/default/rcS
VERBOSE=yes

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

RETVAL=0

start() {
echo -n "Starting PHP FastCGI: "

start-stop-daemon --start --quiet --background \
--chuid $USER --pidfile $PIDFILE --make-pidfile \
--exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
start-stop-daemon --stop --quiet --chuid $USER \
--pidfile $PIDFILE
RETVAL=$?
sleep 1
rm -f $PIDFILE
rm -f $BIND
echo "$PHP_CGI_NAME."
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop
sleep 1
start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit $RETVAL

[/code]
Re: Dummy question readv() failed 104
February 20, 2010 11:36AM
Hello,

Please share your /etc/php-fpm.conf and configuration file of your site for
nginx here ( rapidshare, ... ) .

On 19 February 2010 23:54, xengine <nginx-forum@nginx.us> wrote:

> If i run the script on php-cgi mode at console works like a charm!
>
> I'm using nginx version: nginx/0.8.33
>
> and fastcgi script on ubuntu:
>
>
> #! /bin/sh
> #
> ### BEGIN INIT INFO
> # Provides: php-fastcgi
> # Required-Start: $all
> # Required-Stop: $all
> # Default-Start: 2 3 4 5
> # Default-Stop: 0 1 6
> # Short-Description: Start and stop php-cgi in external FASTCGI mode
> # Description: Start and stop php-cgi in external FASTCGI mode
> ### END INIT INFO
> #
> # Do NOT "set -e"
> # Default values are enclosed in []
>
>
> # Read configuration data
> NAME=php-fastcgi
> DESC="php-cgi runing in external FASTCGI mode"
> PIDFILE=/var/run/nginx/$NAME.pid
> SCRIPTNAME=/etc/init.d/$NAME
>
> # Daemon pathname and args
> #BIND=127.0.0.1:9000
> BIND="/var/run/nginx/$NAME.sock"
> USER=www-data
> PHP_FCGI_CHILDREN=8
> PHP_FCGI_MAX_REQUESTS=250
> export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS
>
> PHP_CGI=/usr/bin/php-cgi
> PHP_CGI_NAME=`basename $PHP_CGI`
> PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin
> PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN
> PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -q -b $BIND"
>
> # Exit if php-cgi is not installed
> [ -x "$PHP_CGI" ] || exit 0
>
> # Load rcS variable settings and set (re)start/stop verbosity
> [ -f /etc/default/rcS ] && . /etc/default/rcS
> VERBOSE=yes
>
> # Define LSB log_* functions.
> # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
> . /lib/lsb/init-functions
>
> RETVAL=0
>
> start() {
> echo -n "Starting PHP FastCGI: "
>
> start-stop-daemon --start --quiet --background \
> --chuid $USER --pidfile $PIDFILE --make-pidfile \
> --exec /usr/bin/env -- $PHP_CGI_ARGS
> RETVAL=$?
> echo "$PHP_CGI_NAME."
> }
> stop() {
> echo -n "Stopping PHP FastCGI: "
> start-stop-daemon --stop --quiet --chuid $USER \
> --pidfile $PIDFILE
> RETVAL=$?
> sleep 1
> rm -f $PIDFILE
> rm -f $BIND
> echo "$PHP_CGI_NAME."
> }
>
> case "$1" in
> start)
> start
> ;;
> stop)
> stop
> ;;
> restart|force-reload)
> stop
> sleep 1
> start
> ;;
> *)
> echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
> exit 1
> ;;
> esac
> exit $RETVAL
>
>
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?3,55379,55380#msg-55380
>
>
Re: Dummy question readv() failed 104
February 20, 2010 10:39PM
My nginx configuration:

/etc/nginx/nginx.conf
[code]
user www-data;
worker_processes 4;

error_log /var/log/nginx/error.log;
pid /var/run/nginx/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
sendfile on;
#tcp_nopush on;

keepalive_timeout 65;
tcp_nodelay on;
access_log /var/log/nginx/access.log;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
[/code]

/etc/nginx/site-enabled/mysite.conf

[code]
server {
listen 80 default;
root /var/www;
index index.php index.html;

# output compression saves bandwidth
gzip on;
gzip_http_version 1.1;
gzip_min_length 1000;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript
text/xml application/xml application/xml+rss text/javascript;

# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
gzip_buffers 16 8k;

# Disable gzip for certain browsers.
gzip_disable msie6;

access_log /var/log/nginx/mysite.access.log;
error_log /var/log/nginx/mysite.error.log;

# Set custom error
include /etc/nginx/custom.error.conf;

#favicon direct
location = /favicon.ico {
access_log off;
expires 30d;
empty_gif;
break;
}

# media
location ~* "\.(jpg|jpeg|gif|css|png|js|ico|swf|flv)$" {
# Return 404 if not exists
if (!-e $request_filename) {
return 404;
}
access_log off;
expires 1d;
break;
}

location / {
if (-f $document_root/maintenance.html ) {
return 503;
}
}

location ~ \.php$ {

if (-f $document_root/maintenance.html ) {
return 503;
}

# Return 404 if not exists
if (!-e $request_filename) {
return 404;
}
# Fast CGI
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/nginx/php-fastcgi.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

}
[/code]

/etc/nginx/fastcgi_params

[code]
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE "Nginx";

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
[/code]

I haven't /etc/php-fpm.conf or i don't found it, i installed Nginx from Jeff Waugh repository and php from ubuntu repositories.
Re: Dummy question readv() failed 104
February 21, 2010 07:56AM
Hello,

You should set the SCRIPT_FILENAME manually. Using default variables does
not return the right path always.
Simply change the following line :
*fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_*
*name;
*to this ine :
*fastcgi_param SCRIPT_FILENAME */var/www*$fastcgi_script_*
*name;*
And it should works correctly.

Regards,
Mostafa Ghadamyari

On 21 February 2010 07:09, xengine <nginx-forum@nginx.us> wrote:

> My nginx configuration:
>
> /etc/nginx/nginx.conf
>
> user www-data;
> worker_processes 4;
>
> error_log /var/log/nginx/error.log;
> pid /var/run/nginx/nginx.pid;
>
> events {
> worker_connections 1024;
> }
>
> http {
> include /etc/nginx/mime.types;
> sendfile on;
> #tcp_nopush on;
>
> keepalive_timeout 65;
> tcp_nodelay on;
> access_log /var/log/nginx/access.log;
>
> include /etc/nginx/conf.d/*.conf;
> include /etc/nginx/sites-enabled/*;
> }
>
>
> /etc/nginx/site-enabled/mysite.conf
>
>
> server {
> listen 80 default;
> root /var/www;
> index index.php index.html;
>
> # output compression saves bandwidth
> gzip on;
> gzip_http_version 1.1;
> gzip_min_length 1000;
> gzip_vary on;
> gzip_comp_level 6;
> gzip_proxied any;
> gzip_types text/plain text/css application/json
> application/x-javascript
> text/xml application/xml application/xml+rss
> text/javascript;
>
> # make sure gzip does not lose large gzipped js or css files
> # see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
> gzip_buffers 16 8k;
>
> # Disable gzip for certain browsers.
> gzip_disable msie6;
>
> access_log /var/log/nginx/mysite.access.log;
> error_log /var/log/nginx/mysite.error.log;
>
> # Set custom error
> include /etc/nginx/custom.error.conf;
>
> #favicon direct
> location = /favicon.ico {
> access_log off;
> expires 30d;
> empty_gif;
> break;
> }
>
> # media
> location ~* "\.(jpg|jpeg|gif|css|png|js|ico|swf|flv)$" {
> # Return 404 if not exists
> if (!-e $request_filename) {
> return 404;
> }
> access_log off;
> expires 1d;
> break;
> }
>
> location / {
> if (-f $document_root/maintenance.html ) {
> return 503;
> }
> }
>
> location ~ \.php$ {
>
> if (-f $document_root/maintenance.html ) {
> return 503;
> }
>
> # Return 404 if not exists
> if (!-e $request_filename) {
> return 404;
> }
> # Fast CGI
> fastcgi_index index.php;
> include /etc/nginx/fastcgi_params;
> fastcgi_pass unix:/var/run/nginx/php-fastcgi.sock;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> }
>
> }
>
>
> /etc/nginx/fastcgi_params
>
>
> fastcgi_param QUERY_STRING $query_string;
> fastcgi_param REQUEST_METHOD $request_method;
> fastcgi_param CONTENT_TYPE $content_type;
> fastcgi_param CONTENT_LENGTH $content_length;
>
> fastcgi_param SCRIPT_NAME $fastcgi_script_name;
> fastcgi_param PATH_INFO $fastcgi_script_name;
> fastcgi_param REQUEST_URI $request_uri;
> fastcgi_param DOCUMENT_URI $document_uri;
> fastcgi_param DOCUMENT_ROOT $document_root;
> fastcgi_param SERVER_PROTOCOL $server_protocol;
>
> fastcgi_param GATEWAY_INTERFACE CGI/1.1;
> fastcgi_param SERVER_SOFTWARE "Nginx";
>
> fastcgi_param REMOTE_ADDR $remote_addr;
> fastcgi_param REMOTE_PORT $remote_port;
> fastcgi_param SERVER_ADDR $server_addr;
> fastcgi_param SERVER_PORT $server_port;
> fastcgi_param SERVER_NAME $server_name;
>
> # PHP only, required if PHP was built with --enable-force-cgi-redirect
> fastcgi_param REDIRECT_STATUS 200;
>
>
> I haven't /etc/php-fpm.conf or i don't found it, i installed Nginx from
> Jeff Waugh repository and php from ubuntu repositories.
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?3,55379,55717#msg-55717
>
>
Re: Dummy question readv() failed 104
February 21, 2010 07:05PM
Thank Mostafa, i made change that you suggest, but still not work.

What could be? and how i check where is the problem? if i use php directly without nginx it works.
Re: Dummy question readv() failed 104
March 05, 2010 11:36PM
Guy, nobody has and idea how to solve it? or where i need to start for? i have a workaround executing the script on cli, basically using system function, but i want to solve it if i can. thank.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 156
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready